14829 Commits

Author SHA1 Message Date
Mohamed Hegazy
ee145ec9f6 Update LKG 2016-11-10 16:28:37 -08:00
Mohamed Hegazy
245a998de5 Merge master into release 2.1 (#12160)
* Use a single ShimMap class, and indicate that iteration always yields string keys (which it did before too)

* Remove emacs-added newline at end of baseline

* Remove space at end of line in baseline

* Add numeric indexer to strings and remove lint

* Update baselines with spread string's numeric indexers

* Reset baseline line number to the locally incorrect value

* Remove trailing newline from baseline again

* Respond to PR comments

* Refactor getTypeFromTypeLiteral, from PR comments

* Fix lint

* Use same literal comparison rules for switch/===

switch was missing the rule for converting literal types to the literal
base type if needed.

* Add switch comparability test and update baselines

* Push eitherIsNotLiteral check into isTypeEqualityComparableTo

Since all callers need this check -- it's how equality is supposed to
work everywhere.

* Update baselines

There are more literal types in error messages because error reporting
no longer has the advantage of calls to getBaseLiteralType

* Adds ES5 to ES3 transformer for reserved words

* Minor cleanup

* Cleaned up emit of enum declaration

* Return both ts and js results from module resolution, and don't have moduleNameResolver responsible for omitting files based on compiler options

* Instead of getResolutionOrDiagnostic, use getResolutionDiagnostic and avoid using resolution.resolvedFileName if the diagnostic is defined.

* Remove "ResolvedModuleFromHost" type and just make `resolvedTsFileName` and `resolvedJsFileName` optional properties

(but still automatically infer one of them to supply if the host supplied neither)

* Remove type inference for spread types

* Update inference test for spread types

* Make spread assignability and apparent type stricter

Assignability now does not allow properties to the left of a type
parameter.
Apparent type now only returns the apparent type of the right-most
spread member.

* Update tests w/spread assignability+apparent type

* Moved AMD/CJS/UMD transform to end

* Spread no longer distributes intersections

* Update spread w/intersection tests

* Move System module transform to end.

* Update baseline

* Revert baseline change due to stale output

* Resolve all-object intersections inside spreads

This means that getSpreadType will return an object type, even when
spreading two intersections, as long as those intersections contain
nothing but object types themselves.

* Update and improve spread intersection tests

* Simplify expression in resolveObjectIntersection

* Update baselines with new index signature rules

* Move n-ary spread handling into separate function.

To be moved to callers in the next step.

* Move multiple-spread handling out of getSpreadType

* Clean up and reorder getSpreadType body

* Respond to PR comments

* Error for call/construct signatures in spread type

1. Simplify the error reporting code to handle all kinds of signatures.
2. Remove index signature handling code when creating a spread type
since it's an error anyway.

* Update baselines with new spread type index errors

* Explain writeSpreadType a little better

* Add more commentary to getSpreadType

* Initial implementation of 'keyof T' type operator

* Introduce PropertyNameType

* Move most of resolveModuleNameForLsHost to lsHost

* Simplify isImplicitGlob test

* Initial implementation of 'T[K]' property access types

* add a fallback logic for older versions of node that don't support 'homedir' (#11845)

* add a fallback logic for older versions of node that don't support 'homedir'

* try os.homedir first

* For JavaScript files, we report semantic errors for using TypeScript-only constructs 
from within a JavaScript file as syntactic errors.

* Don't require `resolvedTsFileName` and `resolvedJsFileName`, just `resolvedFileName` and `extension`. Also, change search order to do all TS searching before searching for JS.

* Fix #10108 (Completion suggestion for object literal with getter) (#11808)

* Fix #10108 (Completion suggestion for object literal with getter)

* completions for setter

* Move helper functions to core (fix build)

* Support parametric property access expressions + some renaming

* rewrite void-returning statements in constructors that capture result of super call (#11868)

* rewrite void-returning statements in constructors that capture result of super call

* linter

* only emit /// types reference for a symbol in d.ts file if all declarations of a symbol come from type reference directives (#11872)

* only emit /// types reference for a symbol in d.ts file if all declarations of a symbol come from type reference directives

* pass proper value for current directory when compiling .d.ts files

* Fix bug: Return a resolution diagnostic for a `.jsx` import if `--allowJs` is turned off

* Remove a comment about a parameter that no longer exists

* Fix bug: We want to test for existence of the enum value, not whether it's non-zero

* Fix: test for presence, not absence

* Allow untyped imports

* Simplify for loops in fourslash.ts

* Rename to zipWith

* Change diagnostic message

* Make `extension` property of `ResolvedModule` optional; introduce `ResolvedModuleFull` interface for when the extension is provided.

* Consider index signatures in type produced by 'keyof T'

* Respond to PR comments

* Refactor getIndexedAccessType to be reusable from checkIndexedAccess

* Skip overloads with too-short function parameters

If the parameter of an overload is a function and the argument is also a
function, skip the overload if the parameter has fewer arguments than
the argument does. That overload cannot possibly apply, and should not
participate in, for example, contextual typing.

Example:

```ts
interface I {
  (a: number): void;
  (b: string, c): void;
}
declare function f(i: I): void;
f((x, y) => {});
```

This code now skips the first overload instead of considering.

This was a longstanding bug but was only uncovered now that more
functions expressions are context sensitive.

* Test skip overloads w/too-short function params

1. Update changed baseline.
2. Add a new test with baseline.

* Minor style improvements

* Ignore optionality when skipping overloads

* Revert "Merge pull request #11354 from Microsoft/map4"

This reverts commit adfdae0dc47db5ad8248d26929a7b31cb895a539, reversing
changes made to aad663cebf6a89f7029af57d8cb6a0a011854978.

* Rename Experimental transform to ESNext

1. Spread/rest are no longer experimental.
2. We need a place to put stage 3 ES features.

* Changes from CR feedback

* disable CoS for inferred projects (#11909)

* Updating test due to CR changes.  The order of the diagnostic messages has changed due to concatenation changes

* Do not use contextual signatures with too few parameters

* isAritySmaller runs later: getNonGenericSignature

* Rename TransformFlags.Experimental -> ESNext

* enable non-ts extensions in inferred projects by default

* update CFG to properly handle do statements

* do not inline async IIFEs in control flow graph

* Minor fixes

* cache type for empty type literal (#11934)

cache type for empty type literal

* Improved error messages for invalid assignments to identifiers

* Accept new baselines

* Improved error messages for invalid assignments to properties

* Accept new baselines

* Improve more error messages

* Accept new baselines

* Fix realPathMap in test harness: Must be used in `directoryExists`

* Add helper function

* Update generated files (#11963)

* Move eitherIsNotLiteral check into switch and === checks

This improves error messages

* Forbid augmentation of untyped module (#11962)

* Forbid augmentation of untyped module

* Just use `undefined` for untyped modules

* Unify checking of indexed access expressions and indexed access types

* Accept new baselines

* Accept additional baselines

* Make `cachingInServerLSHost` tests work with `runtests-browser`

* Get literal type only once

* Update baselines

* Add missed test update

* Improve unification by moving more logic to getIndexedAccessType

* Add test cases to report errors for decorators in js file

* Report all the js file errors and skip only the nodes that are not allowed in js
Fixes #11800

* Fix 'keyof any' to produce 'string | number'

* Fix #11396: Make error message referene `Promise` explicitly (#11982)

* Simplify the checking for async function return type

* Fix https://github.com/Microsoft/TypeScript/issues/11396: Make error message referene `Promise` explicitly

* Minor fixes

* Adding tests

* Test case for property used in destructuring variable declaration

* Mark property referenced in the destructuring as referenced
Fixes #11324

* Spread types handle nested index [access] types

Nested index [access] types are treated as assignable to themselves only,
just like type parameters.

* Test index [access] types inside spread types

* module resolution: prefer locally defined ambient modules, reuse resolutions to ambient modules from the old program (#11999)

module resolution: prefer locally defined ambient modules, reuse resolutions to ambient modules from the old program

* Parse, bind and check rest elements

* Downlevel emit of rest elements

* Add rest tests

* Update baselines

* Remove spread types, leaving spread syntax/emit

Spreads are still typed, but cannot be created from a non-object type.
Tests still need to be updated.

* Fix lint

* Lock tslint version to 4.0.0-dev.0, because 4.0.0-dev.1 complains about unnecessary semicolons following properties

* Remove spread type tests from spread tests

* Spread handles index signatures from singleton spreads

I broke it when simplifying the logic earlier.

* Correct assignability for keyof types and type parameters

* Update tests

* Accept new baselines

* Update objectRestAssignment test and baselines

* Fix linting errors

* Update objectRestAssignment test

Missed previously, just got the baselines

* Improve readability of ES next destructuring emit

* Ensure transformFlags are correct before visiting a node.

* Port #12027, #11980 and #11932 to master (#12037)

* add test for the fix for overwrite emitting error

* cr feedback

* Address PR comments

1. Remove extra line in __rest shim.
2. Improve __rest vs __assign check for destructuring assignment.

* Move convertForOf to factory for esnext and es2015

Saves a lot of duplicated code

* Update improved baselines

* Move transformFunctionBody to factory

It is shared by es2015 and esNext transformers.

This commit just adds a convertObjectRest flag to be passed on to
flattenDestructuring functions, as well as adding necessary parameters
to use the code outside a transformer.

* Spread any types to any

* add missing bind calls to properly set parent on token nodes (#12057)

* Cache generic signature instantiations

* Accept new baselines

* Properly instantiate aliasTypeArguments

* Add regression test

* Revert incorrect logic from #11392

* Accept new baselines

* Rename SpreadElementExpression -> SpreadAssignment

and SpreadExpression (formerly SpreadElementExpression) -> SpreadElement

* Add SpreadAssignment to visitors

1. visitNode
2. reduceNode
3. emit

This fixes an emit bug for setters.

* Add --target esnext

Currently, this disables the rest and spread transforms. This will
change as proposals enter and leave stage 3.

* Add --target esnext tests and update baselines

* Revert unneeded change and comments per PR

* Rename variable in checkSwitchStatement per PR

* Do not emit __rest for --target esnext

* Add `realpath` implementation for lshost

* Create spread property types eagerly

This avoids the need for a synthetic symbol and later code called from
getTypeOfSymbol.

* Set spread type symbols in checkObjectLiteral

Instead of getSpreadType.

Also clean up special-case handling inside getSpreadType to be more
readable.

* Ports #12051 and #12032 into master (#12090)

* use local registry to check if typings package exist (#12014)

use local registry to check if typings package exist

* enable sending telemetry events to tsserver client (#12035)

enable sending telemetry events

* Address more PR comments

* return empty file watcher in case if target directory does not exist (#12091)

* return empty file watcher in case if target directory does not exist

* linter

* property handle missing config files in external projects (#12094)

* Reuse subtree transform flags for incrementally parsed nodes (#12088)

* Port fix for https://github.com/Microsoft/TypeScript/issues/12069 (#12095)

* reduce set of files being watched, increase polling interval (#12054) (#12092)

* Update authors for release-2.1

* Include declaration file emit

* use createHash from ServerHost instead of explicit require (#12043)

* use createHash from ServerHost instead of explicit require

* added missing method in ServerHost stub

* (signature help) type parameter lists are never variadic (#12112)

* Handle abstract and const modifiers

* Downlevel array destructuring to ES6 in object rest

Previously array destructuring inside an object destructuring with an
object rest would downlevel the array destructuring to ES5. This breaks
if the code that targets ES2015 is using iterators instead of arrays
since iterators don't support [0] or .slice that the ES5 emit uses.

* Improve nested destructuring test for ESNext emit

Now with object destructuring inside array destructuring inside object
destructuring! Each with their own array/object rest!

Also updates baselines.

* Add support for taking in jsxFactory option and report errors for invalid combinations

* Treat `| undefined` like optionality in spread type

* Add strictNullChecks test for object spread

* Verify that jsxFactory is either identifier or qualified name

* Resolve first identifier of the jsxFactory as part of type check

* When emitting use jsx factory entity expression if provided

* Transpile unit test case

* Enabled test case for source map

* Add test cases for when jsxFactory cannot be resolved

* Parse the jsxFactory again in the checker instead of using cached value in the program

* Adds error message for incompatible assignment of identically named type

Fixes issue #12050

* Updated condition for more readability

* Report errors for import helpers missing __rest

* Correctly check spread assignments in strict mode

Previously it crashed in the binder.

* Test error for import helpers with no __rest

* synthesize complete import declaration for tslib (#12151)

* Add ES2017 string padding (#12152)

* add es2017.string.d.ts for String.prototype.{padStart,padEnd}

* append es2017.string.d.ts into es2017.d.ts

* add es2017.string into commandLineParser

* append es2017.string into error message for unit tests of commandLineParser

* append es2017.string into Gulpfile

* append es2017.string into Jakefile

* Exclude js files in non-configured projects compile-on-save emitting (#12118)

* Exclude js files in non-configured projects CoS emitting

* remove unnecessary method

* Merge release-2.1 into master (#12157)

* Update LKG

* Update version

* Update LKG

* Skip overloads with too-short function parameters

If the parameter of an overload is a function and the argument is also a
function, skip the overload if the parameter has fewer arguments than
the argument does. That overload cannot possibly apply, and should not
participate in, for example, contextual typing.

Example:

```ts
interface I {
  (a: number): void;
  (b: string, c): void;
}
declare function f(i: I): void;
f((x, y) => {});
```

This code now skips the first overload instead of considering.

This was a longstanding bug but was only uncovered now that more
functions expressions are context sensitive.

* Test skip overloads w/too-short function params

1. Update changed baseline.
2. Add a new test with baseline.

* Minor style improvements

* Ignore optionality when skipping overloads

* Do not use contextual signatures with too few parameters

* isAritySmaller runs later: getNonGenericSignature

* rewrite void-returning statements in constructors that capture result of super call (#11868)

* rewrite void-returning statements in constructors that capture result of super call

* linter

* Update LKG

* Fix emit inferred type which is a generic type-alias both fully and partially fill type parameters

* Add tests and baselines

* Skip trying to use alias if there is target type

* Update baselines

* Add diagnostics to remind adding tsconfig file for certain external project (#11932)

* Add diagnostics for certain external project

* Show tsconfig suggestion

* fix lint error

* Address pr

* fix comment

* Update error message

* Flag for not overwrite js files by default without generating errors (#11980)

* WIP

* Properly naming things

* refactor

* apply the option to all files and check out options

* Fix typo

* Update LKG

* lockLinter

* use local registry to check if typings package exist (#12014) (#12032)

use local registry to check if typings package exist

* Add test for https://github.com/Microsoft/TypeScript/pull/11980 (#12027)

* add test for the fix for overwrite emitting error

* cr feedback

* enable sending telemetry events to tsserver client (#12034) (#12051)

enable sending telemetry events

* Update LKG

* Reuse subtree transform flags for incrementally parsed nodes (#12088)

* Update LKG

* Update version

* Update LKG

* Do not emit "use strict" when targeting es6 or higher or module kind is es2015 and the file is external module

* Add tests and baselines

* [Release 2.1] fix11754 global augmentation (#12133)

* Exclude global augmentation from module resolution logic

* Address PR: check using string literal instead of NodeFlags.globalAugmentation

* Remove comment
2016-11-10 15:43:53 -08:00
Mohamed Hegazy
15dadc70f5 Update version 2016-11-10 12:20:17 -08:00
Yui
f7c40d3d61 [Release 2.1] fix11754 global augmentation (#12133)
* Exclude global augmentation from module resolution logic

* Address PR: check using string literal instead of NodeFlags.globalAugmentation
2016-11-10 10:24:20 -08:00
Yui
6ba4b87dc7 Merge pull request #12134 from Microsoft/release-2.1_fix11806_omitUseStrict
[Release 2.1] fix11806 omit use strict
2016-11-09 17:12:42 -08:00
Kanchalai Tanglertsampan
d629bd636d Add tests and baselines 2016-11-09 15:30:34 -08:00
Kanchalai Tanglertsampan
afea1105c3 Do not emit "use strict" when targeting es6 or higher or module kind is es2015 and the file is external module 2016-11-09 15:30:15 -08:00
Mohamed Hegazy
34d41de06f Update LKG v2.1.2 2016-11-08 12:23:44 -08:00
Mohamed Hegazy
aaf6c1dad4 Update version 2016-11-08 12:11:52 -08:00
Ron Buckton
796a159e63 Update LKG 2016-11-08 12:01:10 -08:00
Ron Buckton
da4985e427 Reuse subtree transform flags for incrementally parsed nodes (#12088) 2016-11-08 12:00:50 -08:00
Mohamed Hegazy
8e8ec9f81d Update LKG v2.1.1 v2.1-rc 2016-11-04 12:01:20 -07:00
Vladimir Matveev
f03e04a41e enable sending telemetry events to tsserver client (#12034) (#12051)
enable sending telemetry events
2016-11-04 11:35:44 -07:00
Zhengbo Li
afe36be50c Add test for https://github.com/Microsoft/TypeScript/pull/11980 (#12027)
* add test for the fix for overwrite emitting error

* cr feedback
2016-11-03 16:26:03 -07:00
Vladimir Matveev
7d1f0e67b4 use local registry to check if typings package exist (#12014) (#12032)
use local registry to check if typings package exist
2016-11-03 15:12:44 -07:00
zhengbli
0b872109b6 lockLinter 2016-11-03 12:48:16 -07:00
Mohamed Hegazy
b98089dc53 Update LKG 2016-11-03 10:35:23 -07:00
Zhengbo Li
73e2328acb Flag for not overwrite js files by default without generating errors (#11980)
* WIP

* Properly naming things

* refactor

* apply the option to all files and check out options

* Fix typo
2016-11-03 10:25:12 -07:00
Zhengbo Li
182bc774b5 Add diagnostics to remind adding tsconfig file for certain external project (#11932)
* Add diagnostics for certain external project

* Show tsconfig suggestion

* fix lint error

* Address pr

* fix comment

* Update error message
2016-11-01 16:42:06 -07:00
Yui
ad9c148168 Merge pull request #11931 from Microsoft/release-2.1_fixDeclarationEmitTypeAlaisWithTypeParam
[Release-2.1] Fix declaration emit when using type parameters
2016-10-31 13:18:32 -07:00
Kanchalai Tanglertsampan
f9a317ec97 Update baselines 2016-10-28 18:16:33 -07:00
Kanchalai Tanglertsampan
f2e343903c Skip trying to use alias if there is target type 2016-10-28 18:16:14 -07:00
Kanchalai Tanglertsampan
01e06f9295 Add tests and baselines 2016-10-28 16:41:17 -07:00
Kanchalai Tanglertsampan
2869f9cb05 Fix emit inferred type which is a generic type-alias both fully and partially fill type parameters 2016-10-28 16:41:10 -07:00
Mohamed Hegazy
467f252583 Update LKG 2016-10-28 10:38:08 -07:00
Vladimir Matveev
86138e33c4 rewrite void-returning statements in constructors that capture result of super call (#11868)
* rewrite void-returning statements in constructors that capture result of super call

* linter
2016-10-28 10:25:34 -07:00
Nathan Shively-Sanders
a163641bd3 isAritySmaller runs later: getNonGenericSignature 2016-10-28 10:14:11 -07:00
Nathan Shively-Sanders
2c09574f18 Do not use contextual signatures with too few parameters 2016-10-28 10:14:06 -07:00
Nathan Shively-Sanders
4e57f700d0 Ignore optionality when skipping overloads 2016-10-28 10:13:59 -07:00
Nathan Shively-Sanders
b4451b159c Minor style improvements 2016-10-28 10:13:51 -07:00
Nathan Shively-Sanders
dfa3dd30fb Test skip overloads w/too-short function params
1. Update changed baseline.
2. Add a new test with baseline.
2016-10-28 10:13:34 -07:00
Nathan Shively-Sanders
1f4d8a1a72 Skip overloads with too-short function parameters
If the parameter of an overload is a function and the argument is also a
function, skip the overload if the parameter has fewer arguments than
the argument does. That overload cannot possibly apply, and should not
participate in, for example, contextual typing.

Example:

```ts
interface I {
  (a: number): void;
  (b: string, c): void;
}
declare function f(i: I): void;
f((x, y) => {});
```

This code now skips the first overload instead of considering.

This was a longstanding bug but was only uncovered now that more
functions expressions are context sensitive.
2016-10-28 10:13:26 -07:00
Mohamed Hegazy
515542b293 Update LKG 2016-10-27 12:55:52 -07:00
Mohamed Hegazy
e497d1ee07 Update version 2016-10-27 12:34:51 -07:00
Mohamed Hegazy
5e9494900a Update LKG 2016-10-25 16:02:19 -07:00
Mohamed Hegazy
19591547db Run tests on branch release-2.1 2016-10-25 15:48:13 -07:00
Vladimir Matveev
72f81e2fc4 Merge pull request #11841 from Microsoft/vladima/report-typings-installer-pid
report typings installer process id to parent process
2016-10-25 15:37:56 -07:00
Vladimir Matveev
7890f63250 use unresolved imports as a source of used typings (#11828) 2016-10-25 15:24:21 -07:00
Zhengbo Li
d0170d1ac8 Support dotted name in @typedef tag (#11695)
* Support dotted name in @typedef tag

* Use a new node flag to get rid of the extra logics

* replace jsdoc namespace node flag with optional property

* Fix linting error
2016-10-25 13:32:48 -07:00
Vladimir Matveev
f48728af74 report typings installer process id to parent process 2016-10-25 13:18:57 -07:00
Asad Saeeduddin
66c1178134 Use symbol fully-qualified name instead of node text in error message (#11761)
* Add test

* Add baselines

* Use fqn of symbol instead of node text
2016-10-25 11:45:32 -07:00
Arthur Ozga
48f947f50d Merge pull request #11829 from Microsoft/arozga/RemoveNavBarWhiteSpace
remove whitespace in nav bar completions
2016-10-25 11:44:29 -07:00
Arthur Ozga
59cfa2eafe remove whitespace 2016-10-25 11:06:04 -07:00
Arthur Ozga
77df58bdb6 simplify regex 2016-10-25 11:03:54 -07:00
Arthur Ozga
476b6e02c8 remove check on property assignment 2016-10-25 10:59:17 -07:00
Sheetal Nandi
d54e889cf2 Merge pull request #11830 from Microsoft/jsDocAV
Fix the AV resulting from presence of undefined in the jsDocPropertyTags
2016-10-25 10:42:49 -07:00
Arthur Ozga
c9b490f234 Merge branch 'master' into arozga/RemoveNavBarWhiteSpace 2016-10-25 10:39:18 -07:00
Arthur Ozga
82e8e43236 only remove whitespace for expr assignment 2016-10-25 10:38:41 -07:00
Sheetal Nandi
f98369b711 Fix the AV resulting from presence of undefined in the jsDocPropertyTags
Fixes #11703
2016-10-24 18:10:05 -07:00
Arthur Ozga
cb804df151 remove whitespace 2016-10-24 17:53:03 -07:00