4311 Commits

Author SHA1 Message Date
Babak K. Shandiz
8e6e87fea6
🐛 Fix smart selection of propery signatures having JSDoc comments (#49804)
* 🐛 Avoid grouping JSDoc nodes of propery signatures with others in smart selection

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>

* ⚗️ Add test case for JSDoc smart selection (#39618)

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>

* ⚗️ Add test baseline for JSDoc smart selection (#39618)

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>

* 🐛 Fix skipping SyntaxList first child's JSDoc in smart selection

Signed-off-by: GitHub <noreply@github.com>

* ⚗️ Add tests to ensure not skipping first SyntaxList child's JSDoc

Signed-off-by: GitHub <noreply@github.com>

* 🔨 Exclude JSDoc token from tokens pivoting property signature

Signed-off-by: GitHub <noreply@github.com>

* ⚗️ Update test case to also include modifier

Signed-off-by: GitHub <noreply@github.com>

* ⚗️ Update test case reference baseline

Signed-off-by: GitHub <noreply@github.com>
2022-07-12 09:04:21 -07:00
Andrew Branch
9dde56c6fc
Add path completions for package.json exports with wildcards (#49644)
* Support path completions for exports wildcards

* Break up results by directory

* Share code between typesVersions and exports processing

* Revert completion kind change

* Add kinds to tests

* Update existing test

* Support nested conditions, improve recursive globbing
2022-07-07 12:26:18 -07:00
AlCalzone
f6684be95e
fix: correct name length criterion for spelling fixes (#49575)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2022-07-07 09:08:37 -07:00
Oleksandr T
7584e6aad6
fix(49642): resolve JsDoc comments/tags if accessors exist in symbol declarations (#49654) 2022-07-06 15:41:50 -07:00
Oleksandr T
cdc1996e87
fix(49426): Object method snippet completions incorrectly add this parameters (#49757)
* fix(49426): omit this parameter

* add OmitThisParameter to TypeFormatFlags

* change flag value
2022-07-05 11:46:19 -07:00
Wesley Wigham
52f4055174
For missing constraint quickfix insert position, Use node name end rather than related span end (#49673) 2022-06-29 11:46:42 -07:00
Nathan Shively-Sanders
cba184f69b
Demote priority of JS completions (#49716)
* Demote priority of JS completions

Fixes #48498

Unchecked JS files gather identifier-based completions. Currently, this search
happens instead of `getCompletionEntriesFromSymbols` for TS/checked JS
files. However, identifier-based completions are much lower quality and
can be ignored by some editors.

Identifier-based completions should be gathered last, after gathering
other completions. That's what this PR does.

* Invert isUncheckedFile to avoid double negative

* dedupe calls to getCompletionEntriesFromSymbols

* Stop re-creating list of entry names

* more deduping + fix lint
2022-06-29 11:05:50 -07:00
bentongxyz
b24b6a1125
fixes #49491 (#49493) 2022-06-22 13:25:01 -07:00
Oleksandr T
74d76e93b3
fix(49546): create computed property name for symbol props (#49554) 2022-06-20 13:46:47 -07:00
Oleksandr T
c01afb5ef3
fix(49548): show completions after keywords in block (#49600) 2022-06-20 12:52:28 -07:00
Andrew Branch
7e7c53961a
Add TS Server option to exclude files from auto-imports (#49578)
* Basic functionality

* Add tests

* Add test for ambient modules

* Add to protocol
2022-06-17 14:39:51 -07:00
Gabriela Araujo Britto
86d5040031
Fix renaming of node_modules (#49568)
* add bug repro test

* add test and start fix implementation

* adjust for useAlias preference

* fix existing renaming test

* refactor to get rid of options

* fix named bindings & other imports cases

* fix eslint error

* address cr comments

* hopefully actually fix eslint

* clean up stale baseline

* make API change non-breaking

* add/fix comments
2022-06-16 17:01:44 -07:00
Oleksandr T
f83ce9bd9c
fix(49566): Implicit this.property completions not returned while writing property (#49574)
* fix(49566): show this.prop completions in class scoped property declaration

* remove duplicate default value
2022-06-16 12:43:50 -07:00
Oleksandr T
180bc4cbea
feat(49385): forbid inlay hints for some kind of initialized declarations (#49412)
.
2022-06-15 15:34:57 -07:00
Wesley Wigham
ba38fe1df2
Expand constraint suggestion related span and add quick fix (#49481)
* Expand constraint suggestion related span and add quick fix

* Remove circular constraint suggestions

* Add error code

* Style feedback and new error code in quickfix
2022-06-15 10:35:51 -07:00
Oleksandr T
806a710470
fix(49478): add return type to method signature (#49482) 2022-06-10 14:14:36 -07:00
Anders Hejlsberg
e6808c4290
Instantiation expression can be followed by line break or binary operator (#49353)
* Allow instantiation expression to be followed by let or interface on new line

* Add tests

* Update src/compiler/parser.ts

* Instantiation expressions followed by line breaks or binary operators

* Add more tests

* Accept new baselines

* Fix lint error

* Update fourslash test

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-06-10 10:26:42 -07:00
Wesley Wigham
ce639352bb
Serialize inaccessible class declarations the same as class expressions in declaration emit (#49440) 2022-06-08 16:33:09 -07:00
Oleksandr T
2f13eba42c
fix(47821): skip nodes with export modifiers (#47829) 2022-06-06 10:49:55 -07:00
TRCYX
44b9745942
fix(49151): format type parameters/arguments (#49165)
Before, the formatter did not consider these constructs as comma
separated lists in general, leading to wrong indentation of '>' after
the list.
2022-05-31 16:03:17 -07:00
Oleksandr T
3da165e3df
fix(49178): check expression with type arguments in inlay hints (#49179) 2022-05-31 15:22:16 -07:00
Anders Hejlsberg
51b346d65a
Improve intersection reduction and CFA for truthy, equality, and typeof checks (#49119)
* Improve reduction of intersection types

* Accept new baselines

* Improve CFA for truthy, equality, and typeof checks

* Accept new baselines

* Remove special case for Function type

* Don't reduce intersections of form {...} & object

* Accept new baselines

* Anything is assignable to unknown-like union

* Accept new baselines

* Tweak subtype check

* Recombine unknown type from unknown-like union in more cases

* Display union origin only if it is shorter than union itself

* Accept new baselines

* Add tests

* Only attach origin type when it is shorter than union itself

* Specially preserve string & {}, number & {}, bigint & {}

* Accept new baselines

* Add additional tests

* Fix getNormalizedType and getNarrowableTypeForReference for intersections

* Switch NonNullable<T> to use T & {}

* Accept new baselines

* Use NonNullable<T> in place of anonymous T & {}

* Accept new baselines

* Add fourslash test

* More fourslash tests

* Fix getFalsyFlags handling of intersections

* Accept new baselines

* Add constraint to compareProperties type parameter

* Unconstrained type parameter not assignable to {} with strictNullChecks

* Accept new baselines
2022-05-27 14:02:54 -07:00
TRCYX
38631e6412
fix(30003): formatter deletes comment after trailing comma (#49168)
Co-authored-by: TRCYX <trcyxs@gmail.com>
2022-05-27 10:09:52 -07:00
Andrew Casey
757a3acbde
Port #48978 forward to the revised FAR code (#49267)
* Port #48978 forward to the revised FAR code

The old regression test didn't catch the corresponding bug in the new code because it hit the fast path where there's only a single project.

* Drop spurious non-null assertion
2022-05-27 09:52:20 -07:00
Andrew Branch
5b86612f68
Fix crash from inaccurate type guard implementation (#49252)
* Fix `isVariableDeclarationInitializedToBareOrAccessedRequire` returning true on binding elements

* Undo auto format change
2022-05-26 16:43:22 -07:00
Andrew Casey
84974838c7
Handle the case where the FAR results map is empty (#49254)
* Handle the case where the FAR results map is empty

Searching exactly one project does not imply the presence of exactly one references list.

Fixes #49217

* Use emptyArray

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2022-05-26 11:00:28 -07:00
Andrew Branch
77ffb96b1a
Fix extensions for noDtsResolution in node16/nodenext (#49233) 2022-05-25 15:27:27 -07:00
Huy
1fb2b2d70f
fix(47562): Add option to suppress type hint if variable name matches type name (#48529)
* fix(47562): Add option to suppress type hint if variable name matches type

* Remove the unnecessary debug code

* Re-run gulp runtests

* Use equateStringsCaseInsensitive to compare strings
2022-05-25 12:07:38 -07:00
Oleksandr T
b57d6e1df4
fix(49131): allow type keyword inside functions (#49134) 2022-05-24 15:16:48 -07:00
Andrew Branch
0921eac6dc
Fix path completions for typesVersions (#49154)
* Fix path completions for typesVersions

* Add more tests

* Fix case when * is a fragment of a path component

* Once a path pattern matches, only return completions from that pattern and higher priority ones

* Fix iteration order issue

* Aesthetics
2022-05-19 14:33:46 -07:00
Andrew Casey
12ed01203c
Clean up FAR aggregation (#48619)
* Clean up FAR and RenameLocations

This change had two goals:

1. Make the code easier to understand, primarily by simplifying the callback structure and minimizing side-effects
2. Improve performance by reducing repeated work, both FAR searches of individual projects and default tsconfig searches

This implementation attempts to preserve the merging order found in the original code (someone less relevant in the present state of using syntactic isDefinition).

* Stop enforcing search and aggregation order

...in preparation for implementing isDefinition explicitly.

Also restore convention of referring to `DocumentPosition`s as "locations".

* Introduce LanguageService.updateIsDefinitionOfReferencedSymbols

...to allow use of the checker when computing isDefinition across projects.

* Update baselines

* Tidy diff

* De-dup simplified results

* Baseline cross-project isDefinition results

* Move de-duping upstream to fix Full output

* Add server baseline test to confirm searches are not repeated

* Manually merge #48758

* Update baseline for newer fix to #48963
2022-05-18 17:26:17 -07:00
Oleksandr T
0df9462a96
fix(49058): Language service crashes for static member in class with unresolved base members (#49059)
* fix(49058): skip unresolved base members

* use getTypeOfSymbol instead of getExportsOfModule
2022-05-16 14:29:40 -07:00
Andrew Branch
08b1cce595
Add regression test for #46192 (#49057) 2022-05-10 16:27:46 -07:00
Zzzen
604e5fca55
Add JSDoc's @inheritDoc Support for Static Class Members for TypeScript (#46719)
* Add JSDoc's @inheritDoc Support for Static Class Members for TypeScript

* use public api

* fix

* add tests

* simplify implementation

* extract comments from inherticDoc
2022-05-09 15:57:27 -07:00
Oleksandr T
69214c0e56
fix(49001): handle missing imports in addMissingMember QF (#49009) 2022-05-09 15:52:15 -07:00
Oleksandr T
aa48a37e09
fix(48673): allow Find All References on access modifier for constructor (#48813) 2022-05-09 14:56:56 -07:00
Andrew Branch
f3f0a3f394
Fix module specifier generation crash from typesVersions (#49035) 2022-05-09 12:48:24 -07:00
Andrew Branch
2ffe6864b1
Respect importModuleSpecifierEnding inside node_modules packages (#48995)
* Respect importModuleSpecifierEnding inside node_modules packages

* Add tests for missing package.json
2022-05-06 12:58:12 -07:00
Andrew Casey
58114cf387
Harden combineProjectOutputForReferences against empty results (#48978)
Getting an empty result doesn't seem expected, but a deeper fix doesn't make sense until #48619 is merged.

Fixes #48963
2022-05-05 13:52:34 -07:00
Andrew Branch
e26bc8a117
Skip missing nodes in formatting (#48953) 2022-05-04 15:07:34 -07:00
Andrew Branch
d879880a37
Don’t let other completions shadow type keywords in type locations (#48939)
* Allow type keywords with the same names as other completions

* Only add type keywords that are the same as other completions in type locations
2022-05-04 08:35:29 -07:00
Mateusz Burzyński
9469f95bd4
Add tests case for function check type being correctly paranthesized in quick info (#48836) 2022-05-03 17:05:37 -07:00
Daniel Rosenwasser
5f9c9a6ccf
Start Node ESM stable version at Node16 (#48879)
* Remove Node12, add Node16.

* Accepted baselines.

* Refactor checking for top-level await, give a better error message in CJS files.

* Accepted baselines.

* Stop erroring on JSON module imports in node ESM since they're no longer experimental.

* Accepted baselines.

* More refactoring, do the same checks for for-await loops.

* Accepted baselines.

* Adjust phrasing to permit for-await on CJS error.

* Accepted baselines.

* Accepted baselines.

* Fix lints.
2022-05-03 16:29:40 -07:00
Gabriela Araujo Britto
8f56f6b49d
Don't go past import in cross-project renaming (#48758)
* WIP

* fix cross-project renaming logic

* only use configure if prefix opt is defined

* refactor skipAlias into stopAtAlias

* fix stopAtAlias

* update another stopAtAlias location
2022-05-03 07:32:44 -07:00
Nathan Shively-Sanders
e73d755668
Fix formatter's processChildNodes (#48921)
processChildNodes needs to skip processing when the node array is
outside the target range, just like processChildNode already does for a
single node.

Fixes #48006
2022-05-02 12:50:24 -07:00
Mateusz Burzyński
63a941dc2a
Add a regression test for completion list in object literal involving inferred obj with optional members (#48910) 2022-05-02 12:27:49 -07:00
Felipe Armoni
fd06132ce9
Fix #47753 - Organize imports removes type imports that are only referenced in @link (jsdoc) (#47824)
* Added unit test

* Added baseline test

* Dirty solution

* Code refactoring and improvements

* Added more test cases

* Refactor to use flatMap

* Added utility function to get all Nodes with JSDocs

* Minor improvements

* Use recursion to check all tree levels

* Removed unit test

* Removed previous changes

* Updated resolveEntityName call

* Updated dontResolveAlias clause

* Updated symbol flags

* Updated baseline

* Fix dont resolve alias problem

* Updated tests
2022-04-29 13:45:00 -07:00
Oleksandr T
9b3853d49e
fix(48851): exclude in from document highlights (#48853) 2022-04-27 17:51:05 -07:00
Andrew Branch
476fc625df
Eagerly resolve module specifiers for auto-import completions in --moduleResolution node12+ (#48752)
* Add failing test

* Block auto-import module specifiers including node_modules path

* Eagerly resolve module specifiers in completions in nodenext so failures can be filtered

* Add completion info flags for telemetry

* Update API baseline

* Update completions baselines

* Fix missed boolean flip

* Fix remaining tests
2022-04-27 16:07:15 -07:00
Oleksandr T
717a1be3c9
feat(48743): allow autocompletion in parameter object destructuring in JavaScript (#48757) 2022-04-27 14:00:01 -07:00