524 Commits

Author SHA1 Message Date
Oleksandr T
1f32fef5a2
fix(51077): skip insertText for jsx attribute with existing initializer (#51093) 2022-12-09 08:38:08 -08:00
Oleksandr T
e087992134
feat(47977): show completion in jsdoc extends/implements tags (#51028) 2022-12-08 17:10:00 -08:00
Gabriela Araujo Britto
a1536358f7
fix & test (#51792) 2022-12-06 16:18:01 -08:00
Gabriela Araujo Britto
6a3c9ea125
Exhaustive case completion for switch statements (#50996)
* fix services' type's isLiteral

* update literal completions tests

* initial prototype

* use symbol to expression. TODO: filter existing, replace import nodes

* WIP

* WIP

* remove booleans from literals

* trigger at case keyword positions

* clean up tests

* fix element access expression case

* refactor dealing with existing values into a tracker

* fix merge errors

* cleanup and more tests

* fix lint errors

* more merge conflict fixes and cleanup

* use appropriate quotes

* small indentation fix

* refactor case clause tracker

* experiment: support tabstops after each case clause

* address small CR comments

* fix completion entry details; add test case

* fix lint errors

* remove space before tab stops; refactor
2022-12-01 16:48:32 -08:00
Jake Bailey
00dc0b6674
Flip imports to case insensitive sorting (#51579) 2022-11-17 15:35:28 -08:00
Jake Bailey
2d2a4343b8
Reformat imports to be one identifier per line (#51565) 2022-11-17 13:42:18 -08:00
Jake Bailey
9f64a3a58c
Remove ts.{Map,Set,ESMap,Iterator} and associated types (#51439) 2022-11-09 15:06:31 -08:00
Jake Bailey
c65142244c Add dts bundling
This adds a "small" d.ts bundler script. This script is very basic,
using Node printing to produce its output. Generally speaking, this is
inadvisable as it completely disregards name shadowing, globals, etc.
However, in our case, we don't care about the globals, and we can opt to
restructure our codebase in order to avoid conflict, which we largely
had to do anyway when we were namespaces and everything was in scope.
2022-11-07 13:35:48 -08:00
Jake Bailey
d12116d8da Fix all internal JSDoc comments
If these are regular comments, then they won't appear in our d.ts files.
But, now we are relying on an external d.ts bundler to produce our final
merged, so they need to be present in the "input" d.ts files, meaning
they have to be JSDoc comments.

These comments only work today because all of our builds load their TS
files from scratch, so they see the actual source files and their
non-JSDoc comments.

The comments also need to be attached to a declaration, not floating,
otherwise they won't be used by api-extractor, so move them if needed.
2022-11-07 13:34:44 -08:00
Jake Bailey
07758c08ab Generated module conversion step - inlineImports
This step converts as many explicit accesses as possible in favor of direct imports from the modules in which things were declared. This restores the code (as much as possible) back to how it looked originally before the explicitify step, e.g. instead of "ts.Node" and "ts.Symbol", we have just "Node" and "Symbol".
2022-11-07 13:33:07 -08:00
Jake Bailey
b6c0538826 Generated module conversion step - stripNamespaces
This step converts each file into an exported module by hoisting the namespace bodies into the global scope and transferring internal markers down onto declarations as needed.

The namespaces are reconstructed as "barrel"-style modules, which are identical to the old namespace objects in structure. These reconstructed namespaces are then imported in the newly module-ified files, making existing expressions like "ts." valid.
2022-11-07 13:32:03 -08:00
Jake Bailey
9a0b85ce2a Generated module conversion step - explicitify
This step makes all implicit namespace accesses explicit, e.g. "Node" turns into "ts.Node".
2022-11-07 13:29:05 -08:00
Jake Bailey
94724a8c2e Generated module conversion step - unindent
This step makes further commits look clearer by unindenting all of the top level namespaces preemptively.
2022-11-07 13:28:13 -08:00
Oleksandr T
7406ee9c14
fix(51170): Completing an unimplemented property overwrites rest of line (#51175)
* fix(51170): skip insertText for class members with existing initializer

* skip insertText for class members with existing tokens
2022-10-17 13:14:23 -07:00
Andrew Branch
938a69a526
Fix import statement completions followed by interface declaration (#50350)
* Fix import statement completions followed by interface declaration

* Fix stuff

* Linty

* Fix when named imports is missing closing brace
2022-09-20 13:29:06 -07:00
Jake Bailey
16156b1baf
Add rules from eslint's recommended set that triggered good lints (#50422) 2022-09-19 16:20:55 -07:00
magic-akari
01cae69e34
fix(50796): omit questionToken in object literal method completions (#50802) 2022-09-16 10:06:03 -07:00
Ron Buckton
a4cabe725b
Support for auto-accessor fields from the Stage 3 Decorators proposal (#49705)
* Support for auto-accessor fields

* Add tests, ensure accessors are initialized in ctor

* classFields cleanup and PR feedback
2022-09-12 15:12:11 -04:00
Oleksandr T
164dddc48e
feat(7481): Operator to ensure an expression is contextually typed by, and satisfies, some type (#46827)
* feat(7481): add explicit type compatibility check with 'satisfies' expression

* Add failing test for lack of intersectioned contextual type

* Implement the behavior

* Add test corresponding to the 'if'

* Add test based on defined scenarios

* remove isExpression in favor of using type casting

* move tests from compiler to conformance folder

* update baseline

* add missing contextFlags argument

* use asserted type

* accept baseline

Co-authored-by: Ryan Cavanaugh <ryanca@microsoft.com>
2022-08-26 10:05:52 -07:00
Andrew Branch
38076df346
Fix auto import crash due to difference in paths handling (#50419) 2022-08-25 13:02:48 -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
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
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
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
Ron Buckton
1e65b330a7
Merge 'decorators' into 'modifiers' on various nodes (#49089)
* Merge 'decorators' into 'modifiers' on various Nodes

* Drop RESERVED argument in favor of removing parameter

* Ignore grammar error nodes when asserting invariants

* Revert 'illegalX' property renames

* PR Feedback
2022-06-09 17:24:02 -07:00
Andrew Branch
00c7c476dc
Avoid repeating codefix work when resolving auto-import specifiers for completions (#49442) 2022-06-09 10:37:16 -07:00
Oleksandr T
b57d6e1df4
fix(49131): allow type keyword inside functions (#49134) 2022-05-24 15:16:48 -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
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
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
Andrew Branch
c99380f87b
Fix auto-import completions sometimes not updating existing imports (#48815) 2022-04-22 15:32:52 -07:00
Andrew Branch
7abdb9e7ef
Format completion snippet text before escaping (#48793)
* Format snippet text before escaping

* Reset `escapes` before printing so printer can be reused
2022-04-21 13:40:14 -07:00
Gabriela Araujo Britto
dfb9f2f953
don't have type annotations on suggested object literal methods (#48607) 2022-04-11 11:33:02 -07:00
Gabriela Araujo Britto
f57bdaa097
Add label details to completion entry (#48429)
* add label details to completion entry

* Use label details for obj literal method completions

* add label details support flag

* add label details support to fourslash

* support both label details and non-label details in object literal method snippets

* CR fixes

* fixes after rebasing

* fix tsserver tests
2022-03-30 12:45:56 -07:00
Gabriela Araujo Britto
e25f04a30f
Enable method signature completion for object literals (#48168)
* skeleton of new feature

* working prototype

* refactor print and format code into its own function

* minor changes; don't support overloads

* have two completion entries

* get rid of accessor support

* add snippet support

* add formatting

* add trailing comma

* add sourcedisplay

* support auto-imports via completion details

* add user preference option and fix ordering of entries

* cleanup

* don't return code actions for no import fixes

* make sortText lower priority for snippets

* get rid of flag

* use optional member sort text

* update baselines

* don't collect method symbols if insert text is not supported

* remove comment

* return undefined if type is not function type

* only slice if needed

* use union reduction; more test cases

* WIP: modify sort text system

* Improve new sort text system

* add signature and union type check

* re-add flag

* fix tests

* rename sort text helper

* fix test and code for union case

* add new flag to protocol type

* fix spaces

* CR: minor fixes

* CR: more fixes

* CR: restructure main flow

* minor fix
2022-03-29 17:19:02 -07:00
Oleksandr T
49a12dcbbb
fix(47081): show completion list in parenthesized object literal arguments (#47104) 2022-03-24 15:30:26 -07:00
Gabriela Araujo Britto
cf8ed8fec1
Change sortText for class member completions (#48196)
* change sortText for class member completions

* update test

* create new sort text member for class snippets

* change values of sort text enum
2022-03-16 16:04:08 -07:00
Gabriela Araujo Britto
e64f04bd8c
Fix modifier order for class member completions (#48066)
* fix modifier order & tests

* remove empty replacement span from tests
2022-03-01 10:05:24 -08:00
Oleksandr T
39fe0318e0
feat(47223): show completion in jsdoc template tag (#47317) 2022-02-15 16:59:37 -08:00
Oleksandr T
867470ca26
fix(47783): show globals completion in case keyword outside of switch statement (#47786) 2022-02-07 14:08:35 -08:00
Andrew Branch
300a53c333
Auto-import perf: Do symbol name/flags filtering before cache rehydration (#47678)
* Do symbol name filtering before cache rehydration

* Fix typo

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>

* Update test

* Fix variable clobbered in merge conflict

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-04 09:17:55 -08:00
Gabriela Araujo Britto
90280518ae
Add assert keyword in completions (#47644)
* add contextual keyword assert in completions

* clean up
2022-01-27 16:17:43 -08:00
Andrew Branch
5813a3541c
Allow moduleSymbolToValidIdentifier to be uppercase for JSX tags (#47625)
* Allow moduleSymbolToValidIdentifier to be uppercase for JSX tags

* Cleaner way of getting the uppercase name when needed

* Fix build errors, get rid of basically unnecessary ScriptTarget

* More accurate name for parameter

* Rename other parameter too

* Fix failing test
2022-01-26 16:12:40 -08:00
Andrew Branch
0d3ff0cce8
Add codefix and completions for promoting existing type-only imports to non-type-only (#47552)
* Import fix

* Wire up completions, add sorting to fix

* Fix overlapping changes when there’s only one import specifier

* Update API baseline

* Add sorting and filtering back to UMD fix
2022-01-26 15:07:41 -08:00
Jake Bailey
3718182a13
Don't block completion after end of type parameters in JSX elements (#47501) 2022-01-26 14:45:21 -08:00
Daniel Rosenwasser
04d77fe900
Update to TypeScript 4.5.5, fix semantic lints. (#47529)
* Update to TypeScript 4.5.5, fix semantic lints.

* Remove extra parens.

* Remove now-outdated non-null comment around #18217.
2022-01-20 11:33:30 -08:00
Andrew Branch
d0b3ac376d
Better reuse of package.json cache, module resolution cache, and package.json auto import filter (#47388)
* Use package.json cache in module specifier generation

* Let AutoImportProviderProject reuse module resolution cache of host project

* Add missing module resolution cache access, add logging to getRootFileNames

* Reuse packageJsonImportFilter

* Only log when the project will be created, update API baseline

* Remove override that could mess up watches
2022-01-18 13:23:13 -08:00
Oleksandr T
8153475ca5
fix(47438): show auto-complete for this inside class static blocks (#47460) 2022-01-18 12:40:00 -08:00