Commit Graph

1299 Commits

Author SHA1 Message Date
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
Sheetal Nandi
94cb657b1c Fix: verification of incremental correctness that was not working because of using wrote writeFile (#48751)
* Use fixed time for vfs so baselining is consistent

* Baseline buildinfos

* Write new file text in baseline even if the file wasnt read on the shadow

* Remove unnecessary debugger statement

* Make sure that incremental correctness is checked with correct writeFile so we know buildInfo was written
Also baseline these so its easy to verify the changes

* More baselines for the tsbuildinfo

* Renames and test fixes after dts Signature change merge

* COmment
2022-04-22 09:30:58 -07:00
Sheetal Nandi
ab2523bbe0 Handles time on vfs and write non empty shadowed files in baseline even if they were not read (#48703)
* Use fixed time for vfs so baselining is consistent

* Baseline buildinfos

* Write new file text in baseline even if the file wasnt read on the shadow

* Remove unnecessary debugger statement
2022-04-21 11:50:28 -07:00
Sheetal Nandi
7a59e45f48 During emit, if shape signature for the file is same as version, then update it with emitted d.ts file (#48616)
* If we are writing dts file and have used file text as version, we can update the signature when doing actual emit

* Make WriteFileCallback Api ready for future

* Assert that there is only single source file when emitting d.ts file
2022-04-21 11:00:34 -07:00
Sheetal Nandi
45faac7e70 If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit (#48600)
* Add test

* Renames

* More refactoring

* If we are updating dts of any of the file and it affects global scope, everything needs update in signature and dts emit
Fixes #42769
2022-04-20 21:05:10 -07:00
Andrew Branch
8bd7ce6feb Find Source Definition (#48264)
* Prototype resolving to JS when go-to-def aliases all resolve to ambient declarations

* Add test infrastructure

* Start fleshing out test coverage

* Fix some go-to-def stuff

* Finish lodash test case

* Make go-to-implementation never return ambient results

* Build new functionality into go-to-implementation

* Update baselines

* Two more test cases

* Refine definition searches for unresolved imports

* Revert "Build new functionality into go-to-implementation"

This reverts commit 381799d0f1.

* Fix tests

* Revert go-to-implementation changes

* Wow a bunch of code was unnecessary

* Update baselines and go-to-def test

* Fix navigation on symbols that are not aliases but resolve through aliases in chain

* Temporarily replace go-to-def with new command implementation

* Revert "Temporarily replace go-to-def with new command implementation"

This reverts commit 34c6cfdebb.

* Revert "Wow a bunch of code was unnecessary"

This reverts commit 1cb2ba646c.

* Bring back some deleted code needed for a new test case

* Clean up a little

* Rename more stuff

* Update test

* Update API baseline

* Temporarily replace go-to-def with new command implementation

* PR review fixes

* Fix getTopMostDeclarationNamesInFile

* Rename local

* Use hash set

* Remove option from commandLineParser

* Keep noDtsResolution project around

* Handle AuxiliaryProject kind in ScriptInfo getDefaultProject etc.

* Do not run updateGraph in the background for AuxiliaryProject

* Don’t create auxiliary project outside of semantic mode

* No-op on scheduled invalidation

* Add comments to unit test

* Sync compiler options to auxiliary project

* Fix case sensitivity

* Update extensionIsOk with new file extensions

* PR feedback

* Update API baseline

* Mark scheduleInvalidateResolutionsOfFailedLookupLocations internal

* Use same heuristics on property accesses of loosely-resolvable aliases as unresolvable named imports

* Rename command, and no need to return the bound span

* Update API baseline
2022-04-14 15:44:19 -07:00
Jake Bailey
e6dcf6f5cb Fix lints after dep update (#48707) 2022-04-14 15:19:22 -07:00
Sheetal Nandi
15c2120a95 Update affected files pending emit when emitting using SemanticDignosticsBuilderProgram (#48519)
* Update affected files pending emit when emitting using SemanticDignosticsBuilderProgram

* Saving of affected files pending emit is not needed any more

* PR feedback
2022-04-11 11:54:39 -07:00
Jack Bates
c1db699482 Don't skip tests named *Fourslash.ts (#48615) 2022-04-11 11:45:44 -07:00
Sheetal Nandi
d8edd191ab Write version for baselining in buildinfo (#48602)
Also baseline buildinfo so its easier to detect mistakes
2022-04-07 13:38:54 -07:00
Sheetal Nandi
4c6f25a998 More refactoring of tsc baselines to help with easier updates (#48572)
* Some refactoring of baselines

* Some refactoring of baselines
2022-04-06 14:10:08 -07:00
Sheetal Nandi
3fd8a6e443 Some refactoring for baselining for easy update (#48516)
* Some refactoring for baselining for easy update

* Set modified time in baseline

* Some renames per feedback
2022-04-06 12:46:34 -07:00
Andrew Casey
76e74370ab Only report isDefinition when FAR is triggered on a definition (#48566)
* Don't report isDefinition unless the starting node is a declaration

* Drop isDefinition everywhere it isn't specifically needed

* Fix tsserver tests

* Update shim comment

* Update baselines

* Add tests for isDefinition

* Update doc comment

* Clear isDefinition from all references if the first one lacks it
2022-04-05 17:04:18 -07:00
Daniel Rosenwasser
c99afde6ad Run API tests with 'strict' and 'exactOptionalProperties'. (#48574) 2022-04-05 13:35:21 -07:00
Minh Quy
6e0447fdf1 [Feature] - Automatically create sort groups based on newlines (#48330)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2022-04-05 11:53:19 -07:00
David Sherret
f654f18d86 fix: ensure ts source file with no-default-lib that augments the global scope gets emitted with incremental program (#48412)
* fix: do not classify non-declaration files as default library source files

* Add test.
2022-04-05 10:00:37 -07:00
Adam Foxman
41aca7c337 Add a new compiler option moduleSuffixes to expand the node module resolver's search algorithm (#48189)
* Add moduleSuffixes compiler option and related tests. Update baselines for compiler options tests.

* Add a flag to the command-line parser which allows "list" params to preserve "falsy" values such as empty strings. Falsy values are normally stripped out.

* Add tests. Rework resolver logic to only run module-suffix code when needed.

* PR feedback

* Add test

* Remove unnecessary conditional.
2022-03-30 15:23:26 -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
Oleksandr T
0cc3535cae revert #44956 - remove hyphen separator (#48416) 2022-03-25 08:21:57 -07:00
Wesley Wigham
8907d7a675 Fix test build post-LKG (#48403) 2022-03-24 12:55:27 -07:00
Wesley Wigham
b5a3a058f5 Merge diagnosticsProducing and nonDiagnosticsProducing checkers into a single checker supporting lazy diagnostics (#36747)
* Merge diagnosticsProducing and nonDiagnosticsProducing checkers into a single checker supporting lazy diagnostics

* Fix lint
2022-03-23 16:21:06 -07:00
Wesley Wigham
26c701c351 Fix document registry cache key calculation for paths compiler option (#48389)
* Fix document registry cache key calculation for `paths` compiler option

* PR feedback
2022-03-23 15:57:39 -07:00
Anders Hejlsberg
6cb58d382f Optional variance annotations (#48240)
* Simplify getVariancesWorker and associated logic

* Accept new API baselines

* Add 'in' and 'out' modififers / add modifiers to type parameters

* Check variance annotations

* Update test runner

* Accept new API baselines

* Allow variance annotations only on certain type parameters

* Add deprecated implementation of createTypeParameterDeclaration

* Accept new API baselines

* Report variance markers as 'sub-XXX' and 'super-XXX'

* Add tests

* Accept new baselines
2022-03-22 11:31:08 -07:00
Jm
fdb1c2fc35 fix: export default anonymous function works with prefixText and suffixText when disabled (#48259) 2022-03-22 10:43:41 -07:00
Thai Pangsakulyanont
9a2868bf98 Infer extracted local variable name from property name (#37902) 2022-03-17 13:39:13 -07:00
Oleksandr T
c981c9ba5a fix(47597): ignore commented imports following template expression (#47657) 2022-03-15 15:28:49 -07:00
Andrew Casey
ce9657d5e2 Introduce set with custom equals and getHashCode (#48169)
* Implement set with custom equals and getHashCode

* Adopt custom set in session

* Add doc comment

* Initially store buckets as non-arrays
2022-03-11 16:17:54 -08:00
Wesley Wigham
d1fa945261 Add moduleDetection compiler flag to allow for changing how modules are parsed (#47495)
* Add moduleDetection compiler flag to allow for changing how modules are parsed

The default setting is 'auto', where JSX containing files under react-jsx and react-jsxdev are
always parsed as modules, and esm-format files under module: node12+ are always parsed as modules,
in addition to the 'legacy' detection mode's conditions for other files. (Declaration files are exempt from
these new conditions)

The 'legacy' mode preserves TS's behavior prior to the introduction of this flag - a file is
parsed as a module if it contains an import, export, or import.meta expression.

In addition, there is a 'force' mode that forces all non-declaration files to be parsed as modules.
(Declaration files are still only modules if they contain a top-level import or export.)

This technically breaks the parser API, but it's kinda-sorta backwards compatible so long
as you don't need the functionality associated with more recent compiler flags.

* Fix post-merge lint

* Rename function

* Update default value documentation

* PR feedback

* Fix lint and typo
2022-03-11 10:36:00 -08:00
Wesley Wigham
c70be8b501 Handle nonmaster branches in user suite tests (#48128)
* Handle nonmaster branches in user suite tests

* Fix remaining changed default branches, vscode & vue-next docker install scripts

* NPM reformats these on install now, comitting so it doesnt need to be ignored

* Accept current user suite baselines

* Fix many trivially fixable user suite tests
2022-03-09 10:31:16 -08:00
Andrew Casey
418989b3c3 Tidy up navto and find-file-references (#48106)
They were using the same helpers as FAR and rename, but they actually behave differently.  Decoupling them helps avoid some unnecessary work and will make it easier to clean up FAR in the future.

Scoping NavTo results to a single project (rather than, e.g. all loaded projects) makes the behavior more logical and the implementation simpler.
2022-03-07 10:56:04 -08:00
Wesley Wigham
ea0db9e031 Add import assertions to type only imports and import types to force the resolution mode of the specifier (#47807)
* Add import assertions for type-only imports and import types to change resolver modes

* By popular request, only allow mode assertions on top-level type only imports

* Add specifier options parameter to specifier generation
2022-03-02 08:54:10 -08:00
Oleksandr T
b0b8cdafc9 feat(44956): remove hyphen separator (#47777) 2022-02-18 13:41:36 -08:00
Wesley Wigham
67172e41c2 Triple-slash reference type directives can override the import mode used for their resolution (#47732)
* Triple-slash reference type directives can override the import mode used for their resolution

They now use the file's default mode by default, rather than always using commonjs. The new arguments to the
reference directive look like:

```ts
///<reference types="pkg" resolution-mode="require" />
```

or

```ts
///<reference types="pkg" resolution-mode="import" />
```

* Omit redundant import modes in emitter

* Add test for #47806

* Add server test for triple-slash reference mode overrides

* Move FileReference mode into helper

* Update tests/cases/conformance/node/nodeModulesTripleSlashReferenceModeOverride3.ts

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

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-02-15 13:53:11 -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
Andrew Casey
7cc0f755ce Use node moduleResolution everywhere (#47687)
TestRunner was already using it, but upstream projects (e.g. Compiler) were not, causing TestRunner to re-parse and re-bind all upstream files in (at least) editor scenarios), slowing down initial project load.

In local testing, this cut a find-all-refs call in checker.ts from 5s to 2.5s.
2022-02-01 15:59:59 -08:00
Andrew Branch
e9092f3723 Proposal: simplify auto import descriptions (#47631)
* Simplify import fix descriptions

* Update tests

* Fix new test
2022-01-27 10:21:08 -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
c191e7c942 Fix diagnostic serialization crash (#47604)
* Add crashing test

* Fix unsafe cast to DiagnosticMessageChain
2022-01-26 10:41:47 -08:00
Joost Koehoorn
ba402e6b86 Allow structure reuse if a declaration file within a package is updated (#47472)
* Allow structure reuse if a declaration file within a package is updated

Closes #47471

* Use correct program to obtain source file in structure reuse test
2022-01-25 11:04:53 -08:00
Jake Bailey
9b6c179089 Fix parser test cases missing 'it' calls (#47545) 2022-01-21 11:32:23 -08:00
Jake Bailey
97017ee5f3 Delay "File change detected" reporting until createProgram (#47427) 2022-01-18 18:13:18 -08:00
Andrew Branch
a158b7ed7d Fix implicit glob detection when ancestor directory contains . (#47418) 2022-01-13 15:33:38 -08:00
Daniel Rosenwasser
ed014db864 Add names for refactoring functions. (#47375)
* Add names for refactoring functions.

* Consistency in function names.
2022-01-11 12:20:17 -08:00
Martin Probst
faee7b3621 Avoid printing comments on static fields twice. (#47363)
* Avoid printing comments on static fields twice.

In TS4.4, when a transformer adds a static field with a synthetic
comment to a decorated class, TS prints the synthetic comment twice:

  @Decorator
  class MyClass {
    /* comment */ staticField = 'x';  // field and comment added by transformer
  }

Becomes:

  var MyClass = class MyClass {}
  /*comment*/
  /*comment*/
  MyClass.newField = "x";
  __decorate(MyClass, Decorator, ...)

This is because the classFields transformer calls `setOriginalNode(n,
propertyDeclaration)` on both the expression statement , and the
assignment expression contained in it, leading to the synthetic comment
appearing twice.

This change avoids the problem by explicitly deleting any synthetic
comments from the assignment expression created for static fields when
creating the expression statement containing the assignment. This allows
us to retain the information of the original node without printing the
synthetic comment twice.

* Update src/testRunner/unittests/transform.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-01-11 12:19:36 -08:00
Andrew Branch
0f1496f354 Process package.json exports with auto-import provider (#47092)
* Have auto-import provider pull in `exports`

* Revert filtering of node_modules relative paths, to do in separate PR

* Do @types and JS prioritization correctly

* Cache entrypoints on PackageJsonInfo

* Add one more test

* Delete unused function

* Fix other tests - dependencies need package.json files

* Do two passes of exports resolution

* Fix missed refactor

* Apply suggestions from code review

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

* Uncomment rest of test

* Handle array targets

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-01-11 11:10:35 -08:00
Kat Marchán
7f189b9701 fix ATA toplevel dep detection (#47164)
ATA tried to use the `_requiredBy` field to determine toplevel deps,
but this is not portable. Not only is it unavailable in npm@>=7, but
neither Yarn nor pnpm write this metadata to node_modules pkgjsons.

This also adds support for ATA acquiring types for scoped packages.

Fixes: https://github.com/microsoft/TypeScript/issues/44130
2022-01-07 13:48:31 -08:00
Orta Therox
8a8c71c147 Use relative paths for the end of compile report (#47344) 2022-01-07 19:55:55 +00:00
Ryan Bargholz
7a12909ae3 fix(45713) Improve error report summaries (#45742)
* Improve error report summaries (#45713)

* fixup! Improve error report summaries (#45713)

* fixup! fixup! Improve error report summaries (#45713)

* Adds support for handling localization renaming the 'files' header due to localization

* fixup! Adds support for handling localization renaming the 'files' header due to localization

 - Fixed baseline error
 - Fixed linter error

Co-authored-by: Orta <git@orta.io>
Co-authored-by: Orta Therox <ortam@microsoft.com>
2021-12-07 10:50:44 +00:00
Andrew Branch
2ce05a8292 Completions sorting overhaul (#46703)
* Sort resolved auto-import completions by number of directory separators

* Sort completions in services layer

* Finish tests

* Fix more tests

* Respect SortText in completions

* Update tests to use `unsorted` assertion
2021-12-03 14:54:51 -08:00
Jack Bates
670ad45bda Describe defaults of more options (#46498)
* Describe defaults of more options

* Use enum members/values vs. strings

* Update Baselines and/or Applied Lint Fixes

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-12-01 07:45:00 -08:00