Commit graph

29896 commits

Author SHA1 Message Date
Anders Hejlsberg 0222211acb
Support for/of variables in assertion checking (#37432)
* Support for/of variables in assertion checking

* Integrate with "dotted name" logic

* Add tests
2020-03-17 19:20:56 -07:00
Alexander T c8e43d878f
fix(37194): fix crash on go to the definition in variable assignment (#37253) 2020-03-17 16:16:28 -07:00
David Sherret 48e1745d6d
Fix Node#getStart(sourceFile, true) throwing when node has a js doc and no parent (#37439)
* Fix missing source file argument.

* Add test

* fix lint

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-17 16:08:57 -07:00
Jack Williams c600aa7411
Fix #33732 (#36077)
* Fix #33732

* Remove code change but keep test
2020-03-17 14:58:52 -07:00
Alexander T 66aa9e77bf
fix(36247): disallow 'constructor' as a parameter property name (#37285) 2020-03-17 14:48:05 -07:00
Josh Goldberg 878f447798
Clarified file-not-found error for reference paths without extensions (#35956)
* Clarified file-not-found error for reference paths without extensions

* Updated error message to include extensions

* update baselines missed in merge

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-17 14:21:23 -07:00
Sheetal Nandi e60bbac84f
Fix declaration emit when the packages are included through symlinks (#37438)
* Convert symlink scenarios to virtual FS where its symlinks are correctly maintained
Adds test for #36866

* Fix the casing issue when redirects differ in casing of the file

* Make ModuleSpecifierResolutionHost internal

* Refactoring for ModuleSpecifierResolutionHost

* If any of the file path option is from node_modules folder, consider only paths in node_modules folder

* Update src/services/utilities.ts

Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-03-17 13:21:40 -07:00
Alexander T a510cad873
fix(36936): fix crash caused by resolving non existent export (#37077) 2020-03-17 13:21:20 -07:00
Alexander T f1eb9898fb
feat(36908): add 'property overwritten by spread' error for jsx attributes. add related span for conflicting declaration in spread (#37329) 2020-03-17 13:13:38 -07:00
Andy Hanson b0450aed56
Add codefix for --noImplicitThis (#27565)
* Add codefix for --noImplicitThis

* Code review

* Back to building post-merge

* Remove redundant functions + update tests

Infer-from-usage also inserts `this: any` parameters when needed, so I
removed that from fixImplicitThis.

Otherwise, fixImplicitThis has better suggestions than inferFromUsage,
so I moved inferFromUsage later in the suggestion order.

* More redundancy removal

Don't need to add `@this` anymore either since inferFromUsage will do
that.

* More baseline updates

From moving inferFromUsage down in priority I think?

* remove now-redundant ad-hoc jsdoc emit

* fix more bad merge

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-17 13:00:14 -07:00
Ron Buckton ec426eec8b
Add script to work around GH issue with suggested reviewers (#37422) 2020-03-17 12:10:55 -07:00
Anders Hejlsberg 9120497a33
Flatten immediately nested conditional types in the false position (#36583)
* Flatten immediately nested conditional types in the false position

* Add test

* Accept new baselines

* Handle nested distributive types with different checkType

* Allow deeply nested immediately resolving conditionals without any syntactic requirements or implementation contortions

Extract logic into function

Co-authored-by: Wesley Wigham <wewigham@microsoft.com>
2020-03-16 16:40:04 -07:00
Sheetal Nandi 2458c8a016
When the imported module is through node_modules and symlink to folder that isnt node_modules (#37387)
* Add tests that fail because of symlink to non common directory node_modules

* When the imported module is through node_modules and symlink to folder that isnt node_modules
Most of the monorepo like scenarios are like this so looking at symlink to decide if file can be imported is essential
Fixes #28689
2020-03-16 11:15:39 -07:00
Anders Hejlsberg b8baf48043
Fix assignment of intersections to objects with optional properties (#37195)
* Treat intersections of only objects as a single object in relations

* Exclude intersections containing non-inferrable types

* Accept new baselines

* Update test

* Accept new baselines

* Add tests
2020-03-14 09:45:05 -07:00
csigs ad8d3d90a5
LEGO: Merge pull request 37390
LEGO: Merge pull request 37390
2020-03-13 15:11:19 -07:00
csigs fa8efcc11b LEGO: check in for master to temporary branch. 2020-03-13 22:10:43 +00:00
Klaus Meinhardt 8b6bd41ce7
getPropertiesOfUnionOrIntersectionType: handle types with index signature (#31979)
* getPropertiesOfUnionOrIntersectionType: handle types with index signature

Fixes: #31565

* fix test

* more testing

* fix typo in checker.ts

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-13 14:30:53 -07:00
Cayman 4432178ded
Add valueOf declarations for TypedArrays (#36668) 2020-03-13 16:50:16 -04:00
Jesse Trinity 4c160683c3
Add trimTrailingWhitespace Editor Option (#36905)
* add trim trailing whitespace option

* set default trimTrailingWhiteSpace to true

* add fourslash tests

* accept new baselines

* only preserce whitespace when setting is explicitly false

* format whitespace
2020-03-13 13:42:49 -07:00
Alexander T fc30095e8b
feat(33792): add new quick fix service to handle missing call in condition (#37152) 2020-03-13 13:38:44 -07:00
Wesley Wigham 47b60ece0b
Make substitution types even if the substitution base isnt a type variable (#37348)
* Make substitution types even if the substitution base isnt a type variable

* Broaden usage of getConditionalFlowTypeOfType to _all_ type lookups

* Align comments
2020-03-13 11:02:11 -07:00
Andrew Branch db44231e38
Add outlining spans for case clauses (#37374)
* Add outlining spans for case clauses

* Update old test

* Update other test

* Update yet another of the same test
2020-03-13 10:52:27 -07:00
Sheetal Nandi ba39113ab9
Handle when default project for file is solution with file actually referenced by one of the project references (#37239)
* Add test where file from referenced project of solution belongs to inferred project instead of referenced project

* Try to find project from project references if the default config project is solution
Fixes #36708

* Add test to verify the correct collection of projects

* Handle when default config project is indirectly referenced in the solution

* Include public API tests in unittests

* Make sure default project for script info is calculated correctly

* Handle reload projects

* Ensure to load solution project tree when project is referenced by solution

* Find all refs when the file is referenced via d.ts

* Some comments per feedback

* Fix typo
2020-03-13 10:46:58 -07:00
Alexander T b41eb1bc61
feat(36249): add quick-fix action to declare a property as private which starts from underscore (#36632) 2020-03-13 10:33:56 -07:00
Orta f1cc8e4e4e
[minor] Adds some docs to the LSP interface (#36740)
* Adds some docs to the LSP dts

* Ensure that getProgramDiagnostic is included everywhere that getCompilerOptionsDiagnostic is

* Update baselines

* Apply suggestions from code review

Co-Authored-By: Andrew Branch <andrewbranch@users.noreply.github.com>

* Remove the getCompilerOptionsDiagnostics -> getProgramDiagnostics change

Co-authored-by: Andrew Branch <andrewbranch@users.noreply.github.com>
2020-03-13 13:26:39 -04:00
csigs eaeee9cc31
LEGO: Merge pull request 37377
LEGO: Merge pull request 37377
2020-03-12 21:11:07 -07:00
csigs 98e45b40d1 LEGO: check in for master to temporary branch. 2020-03-13 04:10:29 +00:00
Sheetal Nandi a7b1717dcb Fix test failure as part of #35922 2020-03-12 18:26:39 -07:00
Sheetal Nandi c1e578df7a Fix tests failure due to #36317 2020-03-12 18:23:43 -07:00
Wesley Wigham df523b30cf
Filter the type of a binding pattern to not include undefined is the pattern parent has an initializer (#37309) 2020-03-12 17:50:05 -07:00
Donald Pipowitch e0f6ecd957
improve error message TS2307 (#27054)
* improve error message TS2307

* add updates missed from merge

* update more missed baselines

* remove incorrectly re-added test files

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2020-03-12 15:55:54 -07:00
Sheon Han b014e2b568
Show token hints for missing closing braces (#36317)
* Add error for missing brace in object literal

* Add new baseline test

* Update all affected tests
2020-03-12 15:52:02 -07:00
Andrii Dieiev c6cfd66fa8
Support template literals in preProcess (fixes #33680) (#33688) 2020-03-12 15:50:23 -07:00
Ryan Cavanaugh 0426e48828
Fix crash when host.getSourceFile returns undefined (#37373)
Another day, another incorrect non-null assertion

Fixes #37368
2020-03-12 15:45:56 -07:00
M.Yoshimura f06f809c75
Treat write-only-access to a class member with setter as a reference. (#35922)
* Treat write-only-access to a class member with setter as a reference.

* Add test case for unused private members, special-casing the member with a setter.
2020-03-12 15:41:40 -07:00
Jack Williams dcc73944f4
Fix 33436 (#35225)
* Fix 33436

* Fix code

* Fix error message after bad merge

* Remove whitespace
2020-03-12 15:40:14 -07:00
Ryan Cavanaugh d727d5a5eb
Remove 'path' from assert call (#37372)
Fixes #37369
2020-03-12 15:11:05 -07:00
Joey Watts 31963d54b8
Add implementation for fixExpectedComma (#33879)
Signed-off-by: Andrew Deniszczyc <adeniszczyc@bloomberg.net>

Cleanup of implementation

Move check node container check

Add test cases for fixExpectedCommaError

Renaming and add test case

Co-authored-by: Andrew Deniszczyc <adeniszczyc@bloomberg.net>
2020-03-12 14:55:02 -07:00
Sachin Grover bff0ddc941
fix(36102): fix extra new line in Organize Imports (#36911)
Organize Imports was inserting extra newline.

Fixes #36102
2020-03-12 17:51:48 -04:00
Arman 3d76c37cbe
More clear comment for String.prototype.match() (#36301)
* More clear comment for String.prototype.match()

* Removed trailing spaces
2020-03-12 14:44:07 -07:00
Klaus Meinhardt 7bd6209fbc
Don't parse duplicate JSDoc for ExpressionStatement starting with ParenthesizedExpression (#36289)
* don't parse JSDoc on ExpressionStatement if it starts with ParenthesizedExpression

* update test
2020-03-12 14:42:49 -07:00
Tom Jenkinson ddcf139668
make splice deleteCount required in es5.d.ts (#32643)
* make splice `deleteCount` required in es5.d.ts

In ES5 `deleteCount` is not an optional argument. If it is not provided it defaults to 0 as a side effect of `undefined` being converted to an integer.

In ES6 `deleleteCount` is optional, and it defaults to the length of the array minus the start index.

If you are targeting ES5 but don't provide `deleteCount` the behaviour will be different depending on the environment your build is running in.

fixes #32638

* update baselines
2020-03-12 14:28:14 -07:00
David 4406717f13
add config to insert space for empty braces (#35427) 2020-03-12 16:35:35 -04:00
Sheetal Nandi a76a16696d
Move useSourceOfProjectReferenceRedirect to program so other hosts can use it too, enabling it for WatchHost (#37370) 2020-03-12 13:11:11 -07:00
Sheetal Nandi 1f710167de
Ensure that we have seenAffectedFiles map when files are added to pending emit because they were present in the old state (#37302)
* Make the systems for baselining default to pretty

* Ensure that we have seenAffectedFiles map when files are added to pending emit because they were present in the old state
This happens in build scenarios since semantic diagnostics are queried before emit and hence files are added to seenAffectedFiles pending emit
Fixes #37269
2020-03-12 10:54:30 -07:00
Anders Hejlsberg 41a80f5d92
No infinite recursion in excess property and weak type checks (#37360)
* New IntersectionState.ExcessCheck flag to ensure no infinite recursion

* Add regression test
2020-03-12 09:40:15 -07:00
Andrew Casey 9e97b00ca1
adds error message for using value as type argument (#37359)
This addresses issue #28975
(https://github.com/microsoft/TypeScript/issues/28975).

When providing a value as a type argument, we can suggest a more specific
error message: "Did you mean to use typeof T?"

adds error message

WIP: Detect error

WIP: progress

updated tests

janky implementation

adds test coverage around literal types being unaffected

refactor out isIdentifierATypeArgument function

adds test case for type alias

adds test case for nested type arguments

fixes linting errors

merge master into branch to overwrite changes

changes value as type error message

This suggests 'typeof T' as a potential alternative when we give an error
about using value T as a type.

remove stale tests from old change

Co-authored-by: John Patterson <john@johnppatterson.com>
2020-03-11 19:18:17 -07:00
Sheetal Nandi 243186685b
Increase the idle time before which ensureProject for open file is called (#37121)
* Increase timeout for ensuring projects for open files

* Condense the project/file printing in the log (given now we have project printed anytime its structure changes)
2020-03-11 16:47:11 -07:00
Wesley Wigham d34af449ca
Recognise master branch-equivalent as master 2020-03-11 15:19:39 -07:00
csigs 5e2b700388
LEGO: Merge pull request 37353
LEGO: Merge pull request 37353
2020-03-11 15:11:08 -07:00