Commit graph

15121 commits

Author SHA1 Message Date
Sheetal Nandi
9fbcb99a33
Emit build info even on noEmitOnError or tsc --build (#38853)
* Emit buildinfo when there are errors with noEmitOnError?
TODO: --build mode

* Always emit tsbuild info even if there are non syntax errors in tsc --build mode

* Sort affectedFilesPendingEmit for consistent build info text
2020-06-02 12:38:40 -07:00
Sheetal Nandi
f0da6d1203
Some changes to tsc baselines for clarity (#38850)
* Baseline programs in tsc -b and tsc -incremental mode as well

* Refactor outFile

* Tests

* Distinct input and output

* Add helper to baseline serialized invocations of tsc on incremental edits

* Input and output in watch mode

* Update src/testRunner/unittests/tsbuild/helpers.ts

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
2020-06-02 11:49:21 -07:00
Jesse Trinity
1d1c1673bf
add support to convert lambda to function and vice-versa (#28250)
* add skeleton

* add getAvailableActions

* add working getEditsForAction

* add multi vardecl

* fix multi decl bug

* change refactor name

* add tests for ToAnon, ToArrow and available arrow

* add tests for ToNamed and available anon

* add tests for ReturnType and available Arrow as FnParam

* fix bug modifiers by toNamed

* add tests for modifiers

* fix for tslint error

* adapt one test case

* refactor getInfo getAvailableActions

* refactor small progress

* extract creation of block

* extract creation of funcDeclaration

* make guideline compliant

* apply feedback from pr

* add testcase and apply feedback from pr

* apply feedback from pr

* add newline

* rename testcases

* Make conditions more expressive

* fix for unnecessary duplication of comment

* apply feedback from pr

* update getAvailableActions

* check if functionExpression name is used

* add more testcases

* do not provide refactoring when it contains this
because this behaves differently in arrow than in function

* exclude nested functions and classes at containingThis check

* fix linting error

* fix line endings

Co-authored-by: BigAru <arooran@indikon.ch>
Co-authored-by: bigaru <bigaru@users.noreply.github.com>
Co-authored-by: Jesse Trinity <42591254+jessetrinity@users.noreply.github.com>
Co-authored-by: Jesse Trinity <jetrinit@microsoft.com>
2020-06-01 15:26:45 -07:00
Wesley Wigham
b36b803cdd
Skip default when initially iterating exports in __importStar, same as __exportStar (#38808)
* Skip default when iterating exports in __importStar, same as __exportStar

* Accept baselines
2020-06-01 14:52:24 -07:00
Jesse Trinity
fb3a84c4f1 fix line endings 2020-06-01 14:15:02 -07:00
Jesse Trinity
52dad733db
Merge branch 'master' into m-lambda-to-fn 2020-06-01 13:53:19 -07:00
Jack Works
8e290e5aae
Improve error range for ts2657 (jsx expr must have parent element), add code fix for it (#37917)
* fix: range of ts2657 (jsx expr must have parent) and remove 2695 (LHS expr of comma has no side effects)

* feat: add code fix for 2657

* fix: resolve review

* chore: hoist a var

* chore: add test for skipTrivia

* fix: rebase error

* Update src/compiler/diagnosticMessages.json

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

* Update src/services/codefixes/wrapJsxInFragment.ts

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>

Co-authored-by: Andrew Branch <andrew@wheream.io>
Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-06-01 12:22:44 -07:00
BigAru
e6dc8f6c69 Merge remote-tracking branch 'upstream/master' into m-lambda-to-fn 2020-05-27 20:33:27 +02:00
Daniel Rosenwasser
f2d6eda60e
Merge pull request #38049 from JoshuaKGoldberg/literal-to-primitive-relation-reporting
Report primitive type in literal-to-primitive relation complaints
2020-05-26 13:18:14 -07:00
Alexander T
6214bd29f3
fix(38722): change error message for use-before-declaration on const enum (#38728) 2020-05-26 11:53:18 -07:00
Nathan Shively-Sanders
bfa1744586
Merge pull request #37894 from microsoft/always-error-on-property-override-accessor
Always error on property override accessor
2020-05-26 10:37:07 -07:00
Anders Hejlsberg
c5b8f4fcd4
Fix relation between generic mapped types and types with index signatures (#38761)
* Fix relation between generic mapped type and type with index signature(s)

* Add tests
2020-05-25 09:55:41 -07:00
Nathan Shively-Sanders
82d9576d9b Merge branch 'master' into always-error-on-property-override-accessor 2020-05-22 07:41:28 -07:00
Daniel
d3d282cb45 Less code 2020-05-22 01:49:26 +00:00
Daniel
afe90f1314 Feed generalized source type to elaboration. 2020-05-22 01:02:27 +00:00
Daniel
a04ecb592c Check constraints deeply on singleton types. 2020-05-22 00:40:28 +00:00
Daniel
8cf2466110 Merge remote-tracking branch 'origin/master' into literal-to-primitive-relation-reporting 2020-05-22 00:09:52 +00:00
Nathan Shively-Sanders
79f1ec32bd Revert "Wrap classes with decorators or static properties in an IIFE, even for ES2015+ (#32011)"
This reverts commit 7cc4a8df94.
2020-05-21 16:23:04 -07:00
Nathan Shively-Sanders
802e87b1eb Merge branch 'master' into always-error-on-property-override-accessor 2020-05-21 16:08:09 -07:00
Wesley Wigham
0018b8f988
Preserve module marker in es2015+ module emit for tool compatability (#38712) 2020-05-21 14:44:23 -07:00
Nathan Shively-Sanders
38715c7b48 remove errant tab 2020-05-21 09:26:42 -07:00
Nathan Shively-Sanders
66f48e303f Switch to isSymbolAccessible for both.
1. Switch to isSymbolAccessible for both types and values, then unify to
a single function.
2. Remove inaccesible base error. We can put it back after making
@implements type reference lookup looser (which may or may not happen).
2020-05-21 09:20:56 -07:00
Nathan Shively-Sanders
9b4a83e8df Merge branch 'master' into fix-implements-tag-emit 2020-05-21 08:21:16 -07:00
kingwl
2997860c2e fix names 2020-05-21 10:23:00 +08:00
kingwl
b73411c985 Fix type and simplify code 2020-05-21 10:19:36 +08:00
Nathan Shively-Sanders
0b531720d4 Make new error an error, not message 2020-05-20 16:53:17 -07:00
Nathan Shively-Sanders
fc83d10388 Merge branch 'master' into diagnose-accidental-accessor-call 2020-05-20 16:46:34 -07:00
Nathan Shively-Sanders
3340142dda
Merge pull request #38607 from a-tarasyuk/bug/38295
fix(38295): Duplicated object key in const not detected when the key is a number preceded by `-` or `+`
2020-05-20 14:52:09 -07:00
Nathan Shively-Sanders
2bb0dabb0f fix untagged argument lint 2020-05-20 14:43:08 -07:00
Alexander T
4e945fbc98
fix(38299): use string literals as keys to creating rest result (#38600) 2020-05-20 13:52:52 -07:00
Nathan Shively-Sanders
68f8f22032
Merge pull request #38425 from dsherret/fixJSDocTagFactoryFuncReturnTypes
Fix some JSDoc factory function return types
2020-05-20 13:22:21 -07:00
Anders Hejlsberg
a56960303d
Intersection check for empty object type shouldn't cause circularities (#38673)
* isEmptyAnonymousObjectType shouldn't require full member resolution

* Add regression test
2020-05-20 10:56:14 -07:00
Nathan Shively-Sanders
c5f66716cf Fix @implements emit for namespaced base types
Fixes #38640
2020-05-20 10:29:39 -07:00
Alexander T
bbf56b044b Merge branch 'master' of https://github.com/microsoft/TypeScript into bug/38295 2020-05-20 20:13:50 +03:00
Dmitry Makhnev
dbaeed5ad8
Add d.ts for Intl.RelativeTimeFormat (#36084)
* feat(lib/es2020.intl): Add `Intl.RelativeTimeFormat` (part of #29129);

* fix(lib/es2020.intl): fix for tests and linters `Intl.RelativeTimeFormat` (part of #29129);

* feat(lib/es2020.intl): Add TSDoc for `Intl.RelativeTimeFormat` by review request https://github.com/microsoft/TypeScript/pull/36084#issuecomment-584769420;

* fix(lib/es2020.intl): Fix for tests;

Co-authored-by: Dmitry Makhnev <dmitriy.makhnev@jugru.org>
2020-05-20 11:06:28 -04:00
Alexander T
e04ab6938a fix(38295): handle duplicate object literal keys which contain '+' and '-' tokens 2020-05-20 14:32:41 +03:00
kingwl
b59e4c51ae Merge branch 'master' into logical_assignment 2020-05-20 10:18:20 +08:00
Wesley Wigham
5f597e69b2
Support naming tuple members (#38234)
* Initial draft of named tuple members

* Show tuple labels and documentation in completions

* Swap allowed syntax to parameter-like

* Add quickfix for labeled tuple syntax mistakes

* Add refactoring to convert list of signatures to single overload

* Fix small bug in visitor verification

* Signature help for rest parameters which are unions of tuples are displayed as seperate entries now

* Expand sanity check test cases in conformance suite

* Add tests and code for preserving tuple names through spreads where possible

* More refactoring tests, some comment preservation and some fixed formatting of multiline tuples

* Handle missing parameter named in isValidDeclarationForTupleLabel

* Minor text fixes
2020-05-19 15:54:02 -07:00
Daniel Rosenwasser
46f100f8ac
Merge pull request #38500 from a-tarasyuk/bug/38485
regression(38485): Unable to specify `rawText` when programmatically creating tagged template literals
2020-05-19 14:24:25 -07:00
Anders Hejlsberg
7ba0a6592d
No contextual types from circular mapped type properties (#38653)
* No contextual types from circular mapped type properties

* Add regression test
2020-05-19 13:42:30 -07:00
Anders Hejlsberg
3c1f37e913
Use control flow analysis to check 'super(...)' call before 'this' access (#38612)
* Use CFA graph to check this/super accesses are preceded by super() call

* Accept cleaned-up API baselines

* Accept new baselines

* Add tests
2020-05-16 19:58:17 -07:00
kingwl
acc167dfc4 fix rebase conflict 2020-05-16 08:13:12 +08:00
kingwl
39ae072a1c add missing semi 2020-05-16 08:10:51 +08:00
kingwl
f78a408ab5 Add more check 2020-05-16 08:10:51 +08:00
kingwl
11bed4456b avoid shouldCaptureInTempVariable 2020-05-16 08:09:46 +08:00
Daniel Rosenwasser
9681c1611c Remove newline 2020-05-16 08:09:46 +08:00
kingwl
be708bbb0a fix assignment check of logical assignment 2020-05-16 08:09:45 +08:00
kingwl
d2be8900dc Add type narrow 2020-05-16 08:09:45 +08:00
kingwl
67a4943e1f Add more case 2020-05-16 08:09:43 +08:00
kingwl
81ce254a73 Refactor logical assignment 2020-05-16 08:09:42 +08:00
kingwl
ff4fca527d Fix cfa 2020-05-16 08:09:40 +08:00
Wenlu Wang
944bcf8459 Update src/compiler/transformers/utilities.ts
Co-Authored-By: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2020-05-16 08:09:39 +08:00
kingwl
ede6214157 Add more check 2020-05-16 08:09:39 +08:00
kingwl
82fe658a48 Add cfa 2020-05-16 08:09:38 +08:00
kingwl
9190a2c4e8 Add contextual types infer 2020-05-16 08:09:38 +08:00
kingwl
f922427196 Add mission semi 2020-05-16 08:09:37 +08:00
kingwl
da16b3e30b Add more case 2020-05-16 08:09:36 +08:00
kingwl
1d93db81cc Add logical assignment operator 2020-05-16 08:09:32 +08:00
Eli Barzilay
33c3e9e2c6 Make processTaggedTemplateExpression visit a returned node
This problem was introduced in 70399e146e (from PR #23801), which added
a `visitTaggedTemplateExpression` case for `TaggedTemplateExpression`,
before that, it would fallback to the default of `visitNode`.  So re-add
that happen in `processTaggedTemplateExpression`.

Since it doesn't hurt, I left a `Debug.checkDefined(property.name)`
instead of `!`-ing it.

Fixes #38558.
2020-05-15 19:46:45 -04:00
Ron Buckton
1cbe7ef000
Fix crash in JS declaration emit (#38508)
* Fix crash in JS decl emit

* Emit as class with private ctor
2020-05-15 14:00:59 -07:00
Wesley Wigham
7fc456f2d7
Include unknown in spread prop override check (#38577) 2020-05-14 14:36:38 -07:00
Greg Hurrell
cfc4573c82 Fix (cosmetic) typos in checker.ts comments
Just some small things I noticed while looking at some recent PRs.
2020-05-14 19:40:41 +02:00
Anders Hejlsberg
c1f676dd3f
Perform intersection reduction before and after getApparentType (#38565)
* Perform intersection reduction before and after getApparentType

* Add regression tests
2020-05-13 20:57:17 -07:00
Daniel Rosenwasser
b682ee1a8a
Merge pull request #38489 from microsoft/removeDuplicateInfo
Remove duplicate JSDoc comments
2020-05-12 12:52:15 -07:00
Daniel Rosenwasser
c2b559403d
Merge pull request #38502 from alan-agius4/export-star-colon
fix: add missing semi-colon to `__exportStar` unnamed function
2020-05-12 10:59:03 -07:00
Nathan Shively-Sanders
cbf15bb6ed
feat(38225): change diagnostic message for remove braces from arrow function body (#38226) 2020-05-12 07:27:09 -07:00
Alan Agius
7ec21e93fe fix: add missing semi-colon to __exportStar unnamed function
Fixes #38501
2020-05-12 13:27:01 +02:00
Alexander T
ee3f2ce362 regression(38485): allow using rawText property in processing a tagged template 2020-05-12 12:30:46 +03:00
Daniel Rosenwasser
f9e1bcd0c4
Merge pull request #38439 from lissein/void-0-template-strings
Changed template strings to emit void 0 instead of undefined (#38430)
2020-05-11 17:09:28 -07:00
Daniel
e9867a7353 Add and use the 'intersperse' helper function. 2020-05-11 22:17:01 +00:00
Ron Buckton
d07e866a28
Fix for jsdoc modifiers on constructor params (#38403)
* Fix for jsdoc modifiers on constructor params

* Update Public API baseline and fix unique symbol grammar check for js
2020-05-11 15:07:43 -07:00
Nathan Shively-Sanders
1a88430a7e
Improve assert message in binder (#38270)
* Improve assert message in binder

Looking at the code, I don't think the assert can ever fire, but it
clearly does, or did in the past. This will make it easier for people to
create a repro.

* fix lint

* Use BindableStaticNameExpression not BindableStaticAccessExpression

This type does allow identifiers, but those are ruled out earlier, so I added
an assert for that case.
2020-05-11 13:40:54 -07:00
Wenqi
1b7b3eb0f7
report error for duplicate @type declaration (#38340) 2020-05-11 12:47:49 -07:00
lissein
946abeadb0 Changed template strings to emit void 0 instead of undefined (#38430)
undefined is not a keyword in es5 and es3 so we now emit void 0 instead in template strings.
2020-05-09 04:53:14 +02:00
Wesley Wigham
7b03835b77
Fix js missing type arguments on existing nodes and jsdoc object literal declaration emit (#38368)
* Fix js missing type arguments on existing nodes and jsdoc object literal declaration emit

* Add special lookups test case, rename helper

* Accept slightly modified baselines
2020-05-08 10:46:28 -07:00
David Sherret
84f89f8702 Fix some JSDoc factory function return types. 2020-05-08 12:26:50 -04:00
Anders Hejlsberg
0091fd6c64
Exclude arrays and tuples from full intersection property check (#38395)
* Exclude arrays and tuples from full intersection property check

* Add regression test
2020-05-07 15:03:51 -07:00
Anders Hejlsberg
7798f532df
Fix crash caused by assertion with evolving array type (#38398)
* Properly finalize evolving array type in getTypeAtFlowCall

* Add regression test
2020-05-07 14:05:57 -07:00
Jack Williams
05d59a1f1a
Unify logic in typeof narrowing (#33434) 2020-05-06 15:15:24 -07:00
Alexander T
683b3ec058
feat(37782): 'declare method' quick fix for adding a private method (#37806)
* feat(37782): add quick-fix action to declare a private method for names that start from underscore

* better merge order in messages json

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-05-06 15:10:02 -07:00
Wenlu Wang
e66ce879a9
expose jsdoc factory (#29539)
* expose jsdoc factory

* refactor jsdoc factory

* correctly jsdoc factory types

* update jsdoc factory

* Add check for delete expression must be optional

* accept new basseline

* Revert "Add check for delete expression must be optional"

This reverts commit 76937c3b1a.

* remove newline

* make linter happy

* Add deprecated comment

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-05-06 15:06:12 -07:00
Nathan Shively-Sanders
35c1ba67ba
Update LKG 2020 05 06 (#38371)
* Update LKG

* remove now-extraneous casts
2020-05-06 14:42:05 -07:00
Josh Goldberg
be2eb8a2e1
Allowed comment directives to be multiline (#38228)
* Allowed comment directives to be multiline

* Added tests, and perhaps fixed a test runner bug?

* I think it's going to need a consistent variable to loop over

* Used dynamically computed indexes in verifies

* Added multiline tests

* Increased flexibility for multiline comment parsing

* Undid a couple of formatting changes; removed backslashes from multiline regexp

* Added baseline tests for multiline comment skipping

Co-authored-by: Orta Therox <orta.therox@gmail.com>
2020-05-06 13:09:29 -07:00
Ron Buckton
4b08c0582d
Fix regression in name resolution in parameter (#38351) 2020-05-06 12:04:28 -07:00
Alexander T
ec93a7cf7b
fix(36055): forbid union type with invalid types in the 'in' operator (#37786) 2020-05-06 11:41:50 -07:00
Anders Hejlsberg
2524fb164a
Consistent narrowing by discriminant (#38311)
* Consistent requirements for narrowing by discriminant

* Add tests
2020-05-05 20:06:07 -07:00
Alexander T
c219fdae08
fix(37703): forbid required parameter after optional (#38155) 2020-05-05 10:29:17 -07:00
Marcel Laverdet
44c6cf74cb
Fix updateBinary operator parameter (#38129)
* Fix `updateBinary` `operator` parameter

There is an issue in `updateBinary` where attempting to update
`operator` without updating `left` or `right` results in a silent no-op.

* Use defaulted parameter in `updateBinary`
2020-05-05 09:05:02 -07:00
Anders Hejlsberg
e6390efb01
Properly handle private/protected members in unions of object types (#38277)
* Property handle private/protected properties in unions of object types

* Add regression test
2020-05-04 15:28:00 -07:00
Wesley Wigham
d9c9c9d9e4
Harden node builder APIs to no longer return undefined for a node when NodeBuilderFlags.IgnoreErrors is provided (#38273) 2020-05-04 14:47:39 -07:00
Sheetal Nandi
aa37b28246
Fix incorrect line text computation to stop comment directive searching (#38296)
Fixes #38289
2020-05-04 13:02:54 -07:00
Anders Hejlsberg
a09470f013
Fix index signatures on unions of intersections (#38278)
* Add missing getApparentType call

* Add regression tests
2020-05-04 12:46:14 -07:00
Eli Barzilay
ba02f4303e Make getAwaitedType private
Also, fix an additional baseline change and break up huge line.
2020-05-04 13:18:52 -04:00
Alexander T
0503da225d feat(36266): add a quick fix for incorrect return types in async functions 2020-05-04 13:18:52 -04:00
Leko
275ed548df disallows exponentials with BigInts for targets lower than ES2016 2020-05-04 13:14:48 -04:00
Wesley Wigham
5b0194b311
Fix jsdoc variadic type nodes not being remapped to equivalent TS in output (#38276) 2020-05-02 01:43:59 -07:00
Andrew Branch
53320f59a4
Fix crash on duplicate default exports (#38272) 2020-04-30 12:21:02 -07:00
Jacob Bandes-Storch
0b1cb74530
fix order and tests 2020-04-29 23:04:24 -07:00
Jacob Bandes-Storch
fd4eccee6c
Merge remote-tracking branch 'upstream/master' into diagnose-accidental-accessor-call 2020-04-29 23:00:16 -07:00
Jacob Bandes-Storch
6051fc1814
move to invocationErrorDetails 2020-04-29 22:58:18 -07:00
Orta
0258db2210
Adds support for looking up past Blocks in expando objects (#38031)
* Adds support for looking up past Blocks in expando objects

* Adds JS tests to validate the JS parsing also works

* Get the top level block expando tests green
2020-04-29 10:35:33 -04:00
Anders Hejlsberg
d9ad27f2dd
Early couldContainTypeVariables check in instantiateType (#37844)
* Shared early couldContainTypeVariables check in instantiateType

* Defer creation of map object in createUnionOrIntersectionProperty

* Types with top-level non-generic type alias reference no type variables
2020-04-28 17:02:52 -07:00
Anders Hejlsberg
3919042c7f
Control flow for constructor initialized properties (#37920)
* Use CFA to determine types of properties declared by this.xxx assignments

* Accept new baselines

* Also use CFA in constructor functions

* Accept new baselines

* Fix lint error

* Only widen fresh literal types in CFA of assignment to auto-typed

* Auto-typing for declared properties with no type annotation or initializer

* Add optionality if declaration includes '?' modifier

* Always use CFA for properties with no initializer in .js files

* Small fix
2020-04-28 16:59:03 -07:00
Anders Hejlsberg
a0ebd2c26e
Guard against recursion in inferTypeForHomomorphicMappedType (#38224)
* Guard against recursion in inferTypeForHomomorphicMappedType

* Add regression test
2020-04-28 16:56:35 -07:00
Anders Hejlsberg
16d2eb7075
Error on this.xxx access of previously declared but uninitialized property (#38030)
* Error on this.xxx access of previously declared but uninitialized property

* Add tests

* Accept new baselines
2020-04-28 12:52:14 -07:00
Nathan Shively-Sanders
12cd15c867
this: undefined in modules (#37784)
It's always supposed to have been this way, but I was worried about how
breaky the change would be when adding globalThisType. This PR is
experiment to see how much.

Fixes #35882 maybe
2020-04-28 10:42:24 -07:00
Alexander T
57f161eaa8 feat(38225): change diagnostic message for remove braces from arrow function body 2020-04-28 10:44:36 +03:00
Josh Goldberg
d4825ab90f I did everything you said I followed all the rules 2020-04-27 19:59:41 -04:00
Daniel Rosenwasser
466d0c0ecb
Bump version number to 4.0 (#38215) 2020-04-27 14:09:58 -07:00
Daniel Rosenwasser
6a6c83cf9a
Revert "Revert "Add check for delete expression must be optional (#37921)" (#38154)" (#38173)
This reverts commit 1b8c68d746.
2020-04-27 13:23:45 -07:00
Wesley Wigham
4a5eeb0bb2
Skip comparing optional property flag when comparing against discriminant properties (#38101) 2020-04-24 18:33:30 -07:00
Daniel Rosenwasser
1b8c68d746
Revert "Add check for delete expression must be optional (#37921)" (#38154)
This reverts commit 39beb1d011.
2020-04-24 16:05:18 -07:00
Ryan Cavanaugh
84c83da3a9
Revert #37106 (#38172) 2020-04-24 16:04:33 -07:00
Ron Buckton
968943f355
Reset error variable in downlevel for-await-of loop (#38170)
* Rename forAwait tests

* Reset error var in for-await loop
2020-04-24 14:59:41 -07:00
Andrew Branch
ce95d9ca6b
Fix values and types merging in JS module exports (#37896)
* Fix values and types merging in JS module exports

* Fix everything

* Share `setValueDeclaration` between binder (local merge) and checker (cross-file merge)

* Revert accidental changes to baselines

* Update baseline from master merge
2020-04-24 13:49:48 -07:00
Wesley Wigham
1785d6c707
Special-case export assigned namespaces in getSpecifierForModuleSymbol so they behave like their containing module symbol (#38151) 2020-04-24 13:10:34 -07:00
Andrew Branch
fe140acc09
Fix truthiness call check for this-property access (#38163) 2020-04-24 13:02:17 -07:00
Ron Buckton
38ff7762ec
Fix temp variable scoping in async generators (#38121) 2020-04-24 12:10:29 -07:00
Ron Buckton
a7d6825e25
Fix temp vars referenced in parameter (#38130)
* Fix temp vars referenced in parameter

* Update error message
2020-04-23 20:45:39 -07:00
Wesley Wigham
815dc90dc5
Issue an error on cross-file merges we cant emit (#38148) 2020-04-23 19:01:16 -07:00
Andrew Branch
9569e8aaa4
Fix newline issues when adding multiple imports (#38119)
* Add new import declarations in a single TextChanges call

* Refactor
2020-04-23 11:59:38 -07:00
Nathan Shively-Sanders
032aa90289
Filter undefined from binding elements with initialisers without undefined in the type (#38122)
* Filter undefined from binding elts w/o undefined-containing inits

* use getTypeOfInitializer instead

* improve comment based on Wesleys suggestion
2020-04-22 15:45:15 -07:00
Nathan Shively-Sanders
f248567dab
Filter undefined only in binding patterns in params (#38116)
initialiser. But this is only correct when the initialiser is for a
parameter. For example:

```ts
declare let x: { s: string } | undefined;
const { s } = x;
```

This PR removes undefined from the type of a binding pattern only when
the binding pattern's parent is a parameter. This fixes the regression
from 3.8. However, it's still not the ideal fix; we should be able to
use control flow to solve this problem. Consider:

```ts
const { s }: { s: string } | undefined = { s: 'hi' }
declare function f({ s }: { s: string } | undefined = { s: 'hi' }): void
```

Neither line should have an error, but the first does in 3.8 and after
this change.
2020-04-22 09:56:32 -07:00
Josh Goldberg
99cdb64839 Used DH's suggested heuristic 2020-04-22 12:48:23 -04:00
Wenlu Wang
39beb1d011
Add check for delete expression must be optional (#37921)
* Add check for delete expression must be optional

* Add more tests
2020-04-22 03:12:01 -07:00
Andrew Branch
7d4fc73331
Fix preserveNewlines printer option when a list child has the same start or end as its parent (#37846)
* Fix preserveNewlines printer option when a list child has the same start or end as its parent

* Fix leading line separator calculation and JSX bug
2020-04-21 15:34:30 -07:00
Wesley Wigham
a72e49e875
Delay pulling on signature contextual type until absolutely needed (#37851) 2020-04-21 13:29:45 -07:00
Wesley Wigham
136f728bb0
Fix js declaration emit for inherited and this-typed inherited fields (#37970) 2020-04-21 13:13:50 -07:00
Nathan Shively-Sanders
6ea291a142
Remove superCallShouldBeFirst error (#37947)
* Remove superCallShouldBeFirst error

It seems redundant since TS gives an error on any use of `this` before
super, and non-`this` uses before `super` should be fine.

Fixes #37371

* Revert "Remove superCallShouldBeFirst error"

This reverts commit 3c09153c8a.

* error except for target:"esnext" && useDefineForClassFields
2020-04-21 12:58:37 -07:00
Nathan Shively-Sanders
63ff6572ae
Fix use-before-def with methods on esnext+useDefineForClassFields (#38033)
* Fix use-before-def with methods on esnext+useDefineForClassFields

It was incorrectly flagging methods as used before their definition, but
this is allowed under any emit.

* Add instance function test case
2020-04-21 08:09:25 -07:00
Josh Goldberg
d12b741004 Excluded type unions from the generale source types 2020-04-20 23:32:34 -04:00
Sheetal Nandi
e7774c6144
Handle non literal computed name when trying to get the name for object literal property name in json object (#37988)
Fixes #37984
2020-04-20 12:58:38 -07:00
Eli Barzilay
9c1157a801
fix(37242): add reference to return type for JSDocFunctionType (#37911) 2020-04-20 14:17:03 -04:00
Anders Hejlsberg
5d78cbdbbd
Propagate nonInferrableType in &&, || and ?? operators (#38035)
* Propagate nonInferrableType in &&, || and ?? operators

* Add regression test

* Simpler solution: getTypeFacts(neverType) should return TypeFacts.None
2020-04-20 11:04:24 -07:00
Josh Goldberg
035b9ac1c1 Lint fix 2020-04-19 22:09:53 -04:00
Josh Goldberg
769a2f2cfc Eased up on some of the more aggressive reporting changes 2020-04-19 20:25:24 -04:00
Josh Goldberg
b14b231d26 Report primitive type in literal-to-primitive relation complaints 2020-04-19 13:26:38 -04:00
Jacob Bandes-Storch
d00f2b53ad
replace the original not-callable error 2020-04-18 21:23:31 -07:00
Alexander T
a2628c9088 fix(37242): add reference to return type for JSDocFunctionType 2020-04-17 09:05:23 +03:00
Wesley Wigham
deb5bac520
Use string representation for negative numeric property names (#37936) 2020-04-15 21:11:05 -07:00
Wesley Wigham
cdc384006c
Fix crash on declaration emit for globalThis (#37992) 2020-04-15 13:37:51 -07:00
Alexander T
a16c44180a
fix(37940): add space after parameter decorator (#37959) 2020-04-15 11:42:29 -07:00
okmttdhr
06e05f25e1
Improve error message for computed enums (#37790)
* Add error message for computed enums

* Add test case for computed enums

* Accept baselines

* Fix returned value when error
2020-04-15 13:50:33 -04:00
Anders Hejlsberg
92cd3ae299
No iteration type errors during CFA (#37965)
* No iteration type errors during CFA

* Add regression test
2020-04-15 10:34:07 -07:00
Ashley Claymore
4538640d8a
Added error when Enum member initaliser references itself (#34655)
Fixes #34606
2020-04-14 15:20:19 -04:00
Wesley Wigham
edd4e0a42b
Add fastpath to isRelatedTo for type references (#37481)
* Add fastpath to isRelatedTo for type references

* Do not check intersections or unions to ignore propegating reference flags, properly set comparing jsx flag

* Re-remove unneeded check

* Just check for TypeFlags.Object

* Remove else clause
2020-04-13 15:54:37 -07:00
Wesley Wigham
6a5508b343
Update __exportStar helper to skip default and __esModule members (#37236)
* Update __exportStar helper to skip default and __esModule

* Accept new baselines

* Remove esmodule check from helper
2020-04-13 13:10:24 -07:00
Wesley Wigham
141ee01c8c
Retain imports in declaration emit if they augment an export of the importing file (#37820)
* Retain imports in declaration emit if they augment an export of the importing file

* (sp)

* Check that a merge occurs, just because
2020-04-13 12:31:14 -07:00
Nathan Shively-Sanders
5f46d42ad1
Error on missing BigInt in es2020 (#37899)
* Error on missing BigInt in ES2020 too.

Previously it was only on ESNext, but bigint ships in ES 2020.

There are no tests for this; passing `false` doesn't cause any tests to
fail at least.

* add tests
2020-04-13 08:30:59 -07:00
Jacob Bandes-Storch
d00a5c954f
Add _0_is_declared_here pointing to accessor declaration 2020-04-11 15:58:35 -07:00
Jacob Bandes-Storch
61f60057f1
Better error message for accidental calls to get-accessors 2020-04-11 15:52:17 -07:00
Nathan Shively-Sanders
eb105efdcd
Avoid circular reference in this-property assignments (#37827)
* Avoid circular reference in this-property assignments

To do this, don't check this-property assigments that have the
this-property of the lhs appearing somewhere on the rhs:

```js
class C {
  m() {
    this.x = 12
    this.x = this.x + this.y
  }
}
```

I tried suppressing the circularity error, but because we cache the
first type discovered for a property, this still results in an implicit
any for `x` in the previous example. It just doesn't have an error.

Fixes #35099

* Add test case + rename function

* Use isMatchingReference
2020-04-10 16:41:31 -07:00
Alexander T
795a5c83fe
fix(37150): ignore private fields in string index type checking (#37183) 2020-04-10 12:53:53 -04:00
Anders Hejlsberg
52dc9f2282
No recursive intersection property checks (#37854)
* No recursive intersection property checks

* Add comment
2020-04-09 19:23:36 -07:00
Anders Hejlsberg
6b1c102bd1
No excessive stack depth global errors (#37873)
* Report excessive stack depth on current node when no error node available

* Accept new baselines
2020-04-09 19:05:35 -07:00
Nathan Shively-Sanders
3030cd8eff refactoring done except for deduping 2020-04-09 16:43:31 -07:00
Andrew Branch
95cc1c279e
Fix crash from missing valueDeclaration on intersection property (#37696)
* Add crashing test

* Fix missing valueDeclaration on intersection symbol property

* Remove assertion from serializeAsClass
2020-04-09 14:00:21 -07:00
Ron Buckton
4a646c9640
Fix parenthesization rules for yield (#37849) 2020-04-09 13:17:46 -07:00
Ravi van Rooijen
2a25901c54
Fix code block in jsdoc (#37864) 2020-04-09 13:31:41 -04:00
Andrew Branch
24a17acf2c
Error on invalid uses of namespace export (#37715) 2020-04-09 09:42:16 -07:00
Andrew Branch
57f9076612
Remove extraneous string escape from convert to template string refactor (#37743)
* Add failing test

* Remove extraneous string escape

* Revert unnecessary change
2020-04-09 09:40:28 -07:00
Nathan Shively-Sanders
3ffe253166 Always error when property overrides accessor or vice versa
Previously this was only an error when useDefineForClassFields: true,
but now it's an error for all code. This is a rare mistake to make, and
usually only occurs in code written before `readonly` was available.

Codefix to come in subsequent commits.
2020-04-09 08:27:08 -07:00
Wesley Wigham
3d3854c93d
Set contextual type on elaborated error node rather than passing it, so its discriminated (#37828) 2020-04-09 02:55:39 -07:00
Ron Buckton
5db4e7add3
Fix async function block return expr error in js (#37845) 2020-04-08 15:26:56 -07:00
Wesley Wigham
b4838c8b62
Use comments from host variable declaration when exporting a signature in js declarations (#37594) 2020-04-08 13:32:17 -07:00
Ron Buckton
5a7916962d
Fix metadata serialization for invalid jsdoc types (#37836) 2020-04-08 12:06:40 -07:00
zhangciwu
126c6ab80d
Fix easy misunderstanding "! ===" (#37838)
* Remove unnecessary Non-null assertion operator

* Wrap Non-null assertion operator inside parentheses
2020-04-08 08:17:22 -07:00
Eli Barzilay
e4babd40e0 Skip isBlockScopedNameDeclaredBeforeUse error in interface or type declarations
Fixes #35947.
2020-04-07 16:12:18 -04:00
Eli Barzilay
dcc6c9461e Minor improvement
Get the `declaration` container just once instead of in three places.
(Minor change: one place used to start looking from
`declaration.parent`, but that shouldn't make any difference.)  Also,
don't pass it to the helper functions since they're local anyway.
2020-04-07 16:12:18 -04:00
Orta
3398c9bfe1
Make skipLibCheck: true the default in --init (#37808) 2020-04-07 15:00:44 -04:00
Andrew Branch
3e86f15f51
Disambiguate types with same name from different namespaces in mapToTypeNodes (#37543)
* Disambiguate types with same name from different namespaces in mapToTypeNodes

* Update baseline with additional example

* Fix typo
2020-04-07 10:55:56 -07:00
Nathan Shively-Sanders
7ca6334dbd
Look for outer type parameters on VariableStatements (#37819)
This only applies in JS, where `@template` tags can apply to
initialisers of variable declarations:

```js
/**
 * @template T
 * @returns {(b: T) => T}
 */
const seq = a => b => b
```

Fixes #36201
2020-04-07 08:04:33 -07:00
Anders Hejlsberg
a2609b1f1b
Extra check in assignment of intersections with generic constituents (#37537)
* Consolidated extra property check with intersections

* Fix comment

* Add tests

* Properly propagate intersectionState

* Route property check through recursive type tracking logic

* Accept new baselines

* Skip check when apparent type of source is never

* Accept new baselines

* Only check when apparent type of source is a structured type
2020-04-06 13:36:20 -07:00
Anders Hejlsberg
5a4024dd9d
Generic functions are never context sensitive (#37811)
* Functions with type parameters are never contextsensitive

* Add tests
2020-04-06 11:55:39 -07:00
Nathan Shively-Sanders
eac073894b
Fix serialisation of static class members in JS (#37780)
* Fix serialisation of static class members in JS

Previously static class members would be treated the same way as expando
namespace assignments to a class:

```ts
class C {
  static get x() { return 1 }
}
C.y = 12
```

This PR adds a syntactic check to the static/namespace filter that
treats symbols whose valueDeclaration.parent is a class as statics.

Fixes #37289

* fix messed-up indent

* Extract function
2020-04-03 20:06:05 -07:00
Orta
20ecbb0f46
Allow Source Mapping inside destructuring assignment (#37298)
* Add support for source maps inside of destructured code

* Adds tests for the source maps inside destructured code
2020-04-03 17:23:02 -04:00
Wesley Wigham
7317292782
Consider arrays and tuples within one another as possibly requiring deferral (#37776) 2020-04-03 14:14:13 -07:00
Nathan Shively-Sanders
7cf4b12d88
Fix crash for private identifier in expando assignments (#37764)
* Fix crash for private identifier in expando assignments

It does this by disallowing private identifiers from expando assignments
entirely. I haven't thought of a scenario where they make sense, but I
haven't thought about it exhaustively either.

Fixes #37356

* Update baselines

I think the new error is probably better. It's certainly different!
2020-04-03 10:29:22 -07:00
Wesley Wigham
6d25c01d09
Cache the regularized form of union types (#37749)
* Cache the regularized form of union types

* Inline function because why not

* Introduce two fastpasths into isRelatedTo
2020-04-02 23:54:24 -07:00
Anders Hejlsberg
349ae45a2c
Reduce intersections with conflicting privates, elaborate on reasons (#37762)
* Elaborate on reasons for 'never' intersections

* Accept new API baselines

* Accept new baselines

* Add tests

* Accept new baselines

* Address CR feedback
2020-04-02 18:00:59 -07:00
Nathan Shively-Sanders
527f467926
Remove error when spreading optional any (#37757)
Previously, spreading an optional any gave a bogus error when the name
conflicted with earlier properties in the object literal. Now the code
checks any types for optionality before issuing the error.

Fixes #37740
2020-04-02 15:04:45 -07:00
Wenlu Wang
afc41f095d
Quick fix for functions lacking return expressions (#26434)
* stash

* add surmise for return type

* add support for more case

* add more test case

* add more testcase and fix all test

* fix changed diagnosis

* fix broken test case

* add more case

* rename quickfix

* fix conflict

* fix fix desc

* fix semi

* Avoid replace brace with paren

* Split fix all action

* Add return work in same line

* fix test cases

* rename baseline

* refactor and handle comment

* Support semi

* make helper internal
2020-04-02 10:06:14 -07:00
Wesley Wigham
78a99241d8
Reuse input type nodes when serializing signature parameter and return types (#37444)
* Accept change

* Accept the huge set of ever so slightly changed baselines

* Update return type logic to only reuse nodes if original nodes share scope with current node, like property types, only reuse nodes if symbols referened are acessible, reuse nodes for property signatures, too

* Only reuse nodes when a context is provided (otherwise identifier printback may fail)

* Only track symbol if symbol is found and no error is recorded

* Fix type parameter reuse lookup

* Forbid cjs module.exports references in retained nodes

* Adjust check for cjs export references to not include bad module type in output

* Add symbol to all identifiers we see in existing nodes for quickinfo

* Accept fourslash baseline updates

* Accept slightly updated baseline post-merge

* Do not copy original nodes for error types, replace empty type references with any
2020-04-01 19:50:21 -07:00
Wesley Wigham
15aff05ff6
Explicitly merge module augmentation members into the exports added by export * declarations (#37691)
* Explicitly merge module augmentation members into the exports added by export * declarations

* Use ?., add namespace merge test

* Add missing merged symbol call to handle enum/ns merges during entity name lookup

* Add test with error case

* Handle missing value declarations in more places, unify duplicate declaration error handling to improve assignment declaration duplicate errors
2020-04-01 16:36:28 -07:00
Alexander T
c546988e50
fix(37456): omit type arguments from JsxSelfClosingElement, JsxOpeningElement nodes (#37739) 2020-04-01 16:27:33 -07:00
Wesley Wigham
326e1c9ff8
Disallow partial matches for discriminant properties when generating error messages (#37589) 2020-04-01 15:39:12 -07:00
Alexander T
697d1042eb
fix(37519): forbid trailing comma in a index signature (#37535) 2020-04-01 15:38:10 -07:00
Nathan Shively-Sanders
95a124f802
Fix crash on bad namespace parse (#37626)
* Fix crash on bad namespace parse

`global` inside a class body is parsed as a module declaration, and in
the following example has no body:

```ts
class C {
  global x
}
```

`x` is parsed as a separate ExpressionStatement. This caused a crash in
emit because the code didn't expect a module declaration with no body.

* inline node.body variable

* fix missed references to body
2020-04-01 15:05:49 -07:00
Sheetal Nandi
0b38a9a2b0
Add support for extraFileExtensions on WatchCompilerHost (#37726)
To support typescript-eslint/typescript-eslint#1813
2020-04-01 11:13:21 -07:00
Wesley Wigham
0e48e68ed1
Fix post-LKG build 2020-04-01 10:53:46 -07:00
Simon Jaeger
9c4cbd64fb
fix #32843 : evaluate right scope when checked if all type parameter are unused for jsdoc @template (#33320)
Co-authored-by: magierjones <simon.jaeger@magierjones.de>
2020-03-31 15:32:15 -07:00
Nathan Shively-Sanders
4dc827e22a
Fix emit of simple module.exports.C.prototype pattern (#37719)
Extends the fix of #36108 so that the simple example gets correct emit;
the complex test case I came up with still doesn't work correctly, but
the actual code froma #35228 is fixed.
2020-03-31 14:59:47 -07:00
pizzacat83
a46e9aea10
support 'in' type guard of intersections (#37106) 2020-03-31 13:37:08 -07:00
Andrew Branch
23b500cadf
Don’t offer this. completions on self, window, global, globalThis. Disambiguate this. completions from others in details requests. (#37652)
* Special-case window, self, global, globalThis methods

* Disambiguate global and this property completions in details requests

* Hide the Map<boolean> implementation

* Update old tests

* Replace SymbolOriginKind stringification with dedicated enum
2020-03-31 12:40:57 -07:00
Anders Hejlsberg
2b0f351005
Fix narrow-by-constructor logic (#37698)
* Fix narrow-by-constructor logic

* Add regression test
2020-03-30 19:31:16 -07:00
Nathan Shively-Sanders
f17174ceb0 Fix build after merging #35862 2020-03-30 15:13:20 -07:00
Titian Cernicova-Dragomir
3433434142
Fixed issue where missing method call went unreported if the call target symbol did no have an id assigned or if the called property was used inside the if block on a different target. (#35862) 2020-03-30 14:45:32 -07:00
Jack Williams
0e15b9f245
Make never rest type top-like (#35438)
* Make never rest type top-like

* Add higher-order test

* properly support types which reduce to never

Co-authored-by: Wesley Wigham <wwigham@gmail.com>
2020-03-30 14:16:07 -07:00
Wesley Wigham
2f0cc51fee
Fix contextual types for maybe-async callbacks (#37205)
* Fix contextual types for maybe-async callbacks

* Remove comment
2020-03-30 14:15:51 -07:00
Neal Burger
9cd4b070ab
Add link to documentation in tsconfig.json template generated by tsc --init (#34686)
* Add Advanced Compile Options to --init command

* removed advanced options and descriptioncolumn

* tests: fix tsconfig.json baselines

* tests: fix failing tests

* feat: adjusted link to specification

* fix: removed duplicate increment flag

* chore: moved position back

* return of the comments

* fix for missalignment

* return of the comment
2020-03-30 14:14:00 -07:00