6418 Commits

Author SHA1 Message Date
Sheetal Nandi
591960edb0 Set old program build info as a location to look for from module resolution caches 2022-12-09 14:49:25 -08:00
Sheetal Nandi
207226a9c8 Reusing resolutions in tsserver scenario 2022-12-09 14:49:24 -08:00
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
Oleksandr T
8f2ee38b52
fix(50888): Organize Imports may delete preceding comments when all members of all import statements are unused (#50983)
* fix(50888): preserve preceding comments of the deleted import

* update tests
2022-12-08 17:05:12 -08:00
Sheetal Nandi
3716ffe748
Make getSupportedCodeFixes on LS so it can be proxied by plugins (#51769)
Fixes #28966
2022-12-08 09:52:25 -08:00
Andrew Branch
dc3daa6644
Fix namespace import update bug, simplify, comment, and rename (#51797) 2022-12-06 16:38:33 -08:00
Gabriela Araujo Britto
a1536358f7
fix & test (#51792) 2022-12-06 16:18:01 -08:00
Isabel Duan
ae9c671d59
(fix #50725, #50710) add file extensions in import statements (#51702)
* fixes #50725

* fixed 50710

* fixed broken test

* clean up

* variable rename

* rename variable to newFileBaseName
2022-12-06 09:28:10 -08:00
Wesley Wigham
b23b29b71b
Use formatting newline rather than host newline in extractType (#51764) 2022-12-05 12:47:36 -08:00
Lyu, Wei-Da
0c09d2f172
quick fix for a nullable missing callback function (#51743) 2022-12-05 12:23:59 -08:00
Sheetal Nandi
9e845d2248
Api cleanup for Module and Type Reference directive resolution (#51546)
* Refactoring so CacheWithRedirects has Key and Value type parameters

* ModuleResolutionCache or TypeRefDirectiveCache will look in directory before solving, so ResolutionCache doesnt need this check

* Test showing module resolution is not shared because resolution cache doesnt update own options

* Enable traceResolution on some of the project reference tests

* Simplify CacheWithRedirects and ensure the options are set in all common scenarios so cache can be shared between redirects

* Make failedlookup etc optional in ResolvedModule/TypeRefefWithFailedLookupLocations
Also make accidental public failed lookup internal

* Add new API for module and type ref resolution

* Store auto type reference resolutions

* Modify test to show how using program partially doesnt report resolution diagnostics

* Ensure that resolution diagnostics are reported in filePreocessingDiagnostics so they can be reused when program is reused

* Some cleanup

* Remove the newly added ReoslutionInfo in favor of new APIs

* update
2022-12-05 11:56:33 -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
Oleksandr T
1b75edcec6
fix(51053): Extract type on JSDoc causes an assertion failure (#51056)
* fix(51053): allow extract type from the jsdoc without a host

* change diagnostic message
2022-12-01 16:09:31 -08:00
Sheetal Nandi
7b7f6a75ea
Code refactoring for module resolution api (#51675)
* Refactoring so CacheWithRedirects has Key and Value type parameters

* ModuleResolutionCache or TypeRefDirectiveCache will look in directory before solving, so ResolutionCache doesnt need this check

* Test showing module resolution is not shared because resolution cache doesnt update own options

* Enable traceResolution on some of the project reference tests

* Simplify CacheWithRedirects and ensure the options are set in all common scenarios so cache can be shared between redirects
2022-12-01 10:17:58 -08:00
Andrew Branch
e6d7b526c8
Fix multiline import specifier sorting (#51634)
* Fix multiline import specifier sorting

* Update baselines

* Switch to EmitFlag, set hasTrailingComma on original node array

* Update API baseline

* Update baselines
2022-11-28 15:35:32 -08:00
Sheetal Nandi
c1427c90b6
Convert reuse program structure and tracing of module resolution to baseline for easier updates (#51628)
* Modify all usages of file name lower casing to use custom lower casing method

* Baseline reuse program structure tests for easy update when making changes to module resolution
2022-11-22 20:58:21 -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
Anders Hejlsberg
7b85cd6b72
Numeric literals assignable to enum literals only when values match (#51561)
* Numeric literal assignable to enum literal only when values match

* Accept new baselines

* Update compiler sources

* Accept new baselines

* Fix test runner

* Any numeric literal type is assignable to a computed numeric enum type
2022-11-16 18:56:01 -08:00
Sheetal Nandi
2f2a17ad0b
Removing some unnecessary methods from host and function parameters (#51499) 2022-11-15 17:34:58 -08:00
Sheetal Nandi
c5aea89230
Add alias ResolutionMode for ModuleKind.ESNext | ModuleKind.CommonJs | undefined (#51482)
* Add alias ResolutionMode for ModuleKind.ESNext | ModuleKind.CommonJs | undefined

* ResolutionMode | undefined = ResolutionMode

* More
2022-11-10 16:47:46 -08:00
Jake Bailey
9f64a3a58c
Remove ts.{Map,Set,ESMap,Iterator} and associated types (#51439) 2022-11-09 15:06:31 -08:00
Sheetal Nandi
48aebcdcdb
TypeReference directive reuse (#49750) 2022-11-07 15:15:11 -08:00
Jake Bailey
b9e24eed8f Remove globalThisShim and globalThis modification for TypeScriptServicesFactory
Looking at github, sourcegraph, and internally, nobody appears to use
this factory at all.

It's still used within our testing framework, so I won't remove it, but
we shouldn't be polyfilling globalThis and sticking things onto it these
days.
2022-11-07 13:36:22 -08:00
Jake Bailey
43cf7875b3 Remove Promise redeclaration
Now that we target ES2018, we don't need to declare this ourselves.
2022-11-07 13:36:22 -08:00
Jake Bailey
dc92488da8 Consolidate checks that test if the current environment is Node
When bundled, it's very likely that the function "require" will actually
exist at runtime, so we can't use this to determine if we are running in
Node. Consolidate that logic and use other things to check instead.

This is still not perfectly accurate, but I don't want to change this
_too_ much, lest someone downstream depend on our inconsistent logic.

There are yet other places this commit does not fix; search for "typeof
process" for more examples.
2022-11-07 13:35:48 -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
4139807e75 Add build via esbuild
This configures the existing build tasks to use esbuild by default. If
using the plain files is desired, passing `--bundle=false` will build
using plain files and still produce a runnable system.

This is only a basic build; a more efficient build is provided later
when gulp is replaced by hereby.
2022-11-07 13:34:44 -08:00
Jake Bailey
36e29448e9 Get codebase building pre bundling
This isn't totally complete, but enough to get everything building and
tests running manually. The next commit will make the build work fully.
2022-11-07 13:34:44 -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
39e27fbb6b Fix up linting, make lint clean
Now that we are modules, there's no reason to ban multiple namespaces
per file; each file is its own scope and declaring a namespace won't
merge it into any other files.
2022-11-07 13:33:07 -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
Sheetal Nandi
7b0df1ff99
Pass in information for the module name resolution when resolutions from file are partially used (#49738)
* Test showing wrong resolution is returned because of incorrect mode calculation
Test for #48229

* Pass in information for the module name resolution when resolutions from file are partially used
Fixes #48229

* Make the resolution info complete
2022-11-07 11:51:04 -08:00
Oleksandr T
fa4b49d541
fix(51374): ts(80004): Quick fix... > Annotate with type from JSDoc :: object types (#51378)
* fix(51374): transform JSDocTypeLiteral

* add additional tests

* add additional tests
2022-11-07 11:35:08 -08:00
Andrew Casey
f1d62f4dc4
Change watchdog tagged users (#51411) 2022-11-04 15:23:08 -07:00
Gabriela Araujo Britto
fdcb2ffd1b
Fix services' type's isLiteral implementation (#50929)
* fix services' type's isLiteral

* update literal completions tests

* remove booleans from literals
2022-11-02 11:28:10 -07:00
Oleksandr T
64d0d5ae14
fix(51301): Fixing an unused import at the end of a line removes the newline (#51320)
* fix(51301): keep the line break after removing the unused identifier

* preserve line breaks in import specifiers

* preserve line breaks in parameters and destructuring elements

* remove preserveLineBreak option
2022-10-27 17:27:36 -07:00
Oleksandr T
d4f26c840b
fix(51245): Class with parameter decorator in arrow function causes "convert to default export" refactoring failure (#51256)
* fix(51245): don't rely on parent nodes in formatting rules

* check existing parent node
2022-10-26 16:59:44 -04:00
Oleksandr T
8b1ecdb701
fix(50654): "Move to a new file" breaks the declaration of referenced variable (#50681)
* fix(50654): remove entire import require call instead of the name

* handle require imports in ts files
2022-10-25 17:05:57 -07:00
Oleksandr T
88d25b4f23
fix(50068): Refactors trigger debug failure when JSX text has a ' and a tag on the same line. (#51299)
* fix(50068): rescan JsxText on JsxElement context

* fix lint errors

* add tests
2022-10-25 13:10:31 -07:00
Andrew Branch
ef69116c41
Generate shortest rootDirs module specifier instead of first possible (#51244)
* Generate shortest rootDirs module specifier instead of first possible

* Simplify `min`
2022-10-21 16:05:58 -07:00
Oleksandr T
8ac465239f
change type (#51231) 2022-10-19 12:38:37 -07:00
Oleksandr T
245a02cbed
fix(51222): Go-to-definition on return statements should jump to the containing function declaration (#51227)
* fix(51222): add go-to-definition return statement to containing function

* add additional tests
2022-10-19 11:32:39 -07:00
Oleksandr T
f25bcb7c27
fix(49196): add jsdoc snippet for interface member functions (#51135) 2022-10-17 17:35:08 -07: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
Isabel Duan
2cb7e779d7
fix(50416): correctly names disabled export refactors (#50663)
* added test case to try to retrieve duplicate refactor as in #50416. 'verify.refactorAvailable' correctly retrieves nonduplicate refactors...

* optional arguments in refactorAvailable return `true` even if there is no single refactor that satisfies both

* it still passes :C

* Delete fixExtractToInnerFunctionDuplicaton.ts

* deleted extra test code

* fix 'verify.refactorAvailable' so that tests correctly check for multiple arguments

* fixes #50416

* refactor
2022-10-13 16:44:30 -07:00