Commit Graph

11482 Commits

Author SHA1 Message Date
Jake Bailey
8d0393d227 Fix missing parsingContext restore at return in parseDelimitedList (#48999) 2022-05-06 13:36:27 -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
Wesley Wigham
8e433cda3d Allow export map entries to remap back to input files for a program (#47925)
* Allow export map entries to remap back to input files for a program

* Fix file casing issues on windows

* Implement abiguity error, doesnt quite work

* Refine selection logic in error case to use getCommonSourceDirectory, add more tests
2022-05-05 12:53:56 -07:00
Nathan Shively-Sanders
46e8306050 Skip ambient modules in globalThis (#48938)
* Skip ambient modules in globalThis

Previously, globalThis mistakenly included ambient modules, even though
these are not values:

```ts
declare module "ambientModule" {
  export type typ = 1
  export var val: typ
}
type Oops = (typeof globalThis)[\"ambientModule\"]
```

This PR adds ambient modules to the kinds of things that are skipped
when constructing `globalThis`' properties, along with block-scoped
variables.

* Skip only modules with every declaration ambient

The modules are required to have at least one declaration so that our
treatment of `globalThis` stays the same, and
`globalThis.globalThis.globalThis` remains legal.
2022-05-05 09:33:32 -07:00
Jake Bailey
7d60dc1f5d Revert "feat(47595): allow using private fields in type queries" (#48959) 2022-05-04 16:50:30 -07:00
Andrew Branch
e26bc8a117 Skip missing nodes in formatting (#48953) 2022-05-04 15:07:34 -07:00
Jake Bailey
f579f3307e Revert "Don't treat a colon in a conditional expression branch as part of an arrow function" (#48940) 2022-05-04 15:01:05 -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
Anders Hejlsberg
38c14606b4 Fix blocking of recursive dependencies in getNarrowedTypeOfSymbol (#48941)
* Better blocking of recursive dependencies in getNarrowedTypeOfSymbol

* Add regression test
2022-05-03 14:20:35 -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
Oleksandr T
99ffa394a8 fix(48759): throw an error on using import expression with type arguments (#48787) 2022-04-29 14:19:20 -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
ZHAO Jinxiang
0885482eeb Fix export default expression comment (#48323) 2022-04-27 16:33:46 -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
Nicola Dardanis
d45012c5e2 Add JS-specific diagnostic message for resolve() in Promise where type argument can't be inferred (#48533)
* change error message on Promise

* fix(46570): Unhelpful Promise type argument hint in JS file

* refactor: Reword void Promise message for JSDoc type hint to provide better feedback

Co-authored-by: Osa <osaimola@gmail.com>
2022-04-27 11:55:35 -07:00
Nathan Shively-Sanders
2a78b225d0 Stop tag after @callback from crashing (#48860)
By copying the kludge in @typedef. @callback's order is simpler, so the
kludge is simpler. However, it's wrong here, and in @typedef. Parsing
tag comments is normally supposed to happen at the end of a tag, but in
@callback and @typedef happens *before* parsing the nested
@param/@property tags.

I still need to figure out what a real fix is -- but for the beta,
copying the existing crash-avoidance kludge from @typedef is best
anyway. I added a test case for typedefs for future use as well.
2022-04-27 11:21:10 -07:00
Andrew Branch
7b6b4dc258 Fix getExportSymbolOfValueSymbolIfExported (#48769) 2022-04-26 13:39:20 -07:00
Anders Hejlsberg
787bb9ddb6 Improve support for numeric string types (#48837)
* Improve support for numeric string types

* Update test

* Add tests
2022-04-25 15:36:06 -07:00
Andrew Branch
c99380f87b Fix auto-import completions sometimes not updating existing imports (#48815) 2022-04-22 15:32:52 -07:00
Mateusz Burzyński
af30c79093 Fixed string literal completions for partially-typed strings when overload could get matched (#48811) 2022-04-22 08:36:14 -07:00
Oleksandr T
d71dd1d912 fix(48556): throw an error on jsx spread attributes with an invalid type (#48570) 2022-04-21 16:31:16 -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
John Lusty
273a567617 Fix handling of prologue statements when there are parameter property declarations (#48775) 2022-04-20 08:49:22 -07:00
Wesley Wigham
ce487e4fd3 Fix meta property symbol lookup (#48773) 2022-04-19 17:57:06 -07:00
Andrew Branch
d81a976c14 Ensure enum aliases referenced in other enum members do not get marked as referenced (#48770)
* Add test

* Ensure enum aliases referenced in other enum members do not get marked as referenced
2022-04-19 15:23:25 -07:00
Patrick Szmucer
2e619fdc80 Fix transformed constructor code when there is code between prologue statements and super call (#48765) 2022-04-19 09:19:25 -07:00
Jake Bailey
d3943fc86f Disallow line break between entity name and type arguments in typeof expression (#48755) 2022-04-18 16:18:31 -07:00
Anders Hejlsberg
65f6cb23d3 Constraints for mapped types with filtering 'as' clauses (#48699)
* Constraints for mapped types with filtering 'as' clauses

* Add regression test
2022-04-18 14:24:22 -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
Josh Goldberg
fa2515ecd9 Fixed multiple prologue directives with parameter properties (#48687) 2022-04-14 09:29:15 -07:00
Oleksandr T
73c93eec5c fix(48657): allow JSXElement names to be IdentifierNames (#48661) 2022-04-13 12:32:10 -07:00
Anders Hejlsberg
a027cfa8ac More permissive parsing of instantiation expressions (#48659)
* More permissive parsing of expressions with type arguments

* Add test
2022-04-13 09:16:43 -04:00
Anders Hejlsberg
cce61d1b69 Variance annotations on class expressions + deferred valiation (#48645)
* Variance annotations on class expressions + deferred validation

* Add regression tests
2022-04-12 09:34:33 -04:00
Jack Bates
c1db699482 Don't skip tests named *Fourslash.ts (#48615) 2022-04-11 11:45:44 -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
Andrew Branch
af3e1d4dfd Reuse type nodes from optional parameters even when not written as a union with undefined (#48605)
* Reuse type nodes from optional parameters and properties even when not written as a union with `undefined`

* Remove newly unneeded NodeBuilderFlag

* Update public API

* Update baselines from main
2022-04-08 14:28:36 -07:00
Oleksandr T
3b2fa50a14 fix(48487): allow using private names as the self-assignment entity name (#48496) 2022-04-08 10:48:28 -07:00
LowR
b45cf0d694 disentangle the meaning of SymbolLinks.target (#47098) 2022-04-07 15:40:39 -07:00
Zzzen
f4b99ea47c preserve this when extracting functions (#41992)
* preserve this when extracting functions

* rename IsThisReferringToFunction to UsesThisInFunction

* refactor

* update tests
2022-04-07 15:05:46 -07:00
jihndai
b18141b0bc Do not reset control flow analysis on index signatures (#48427)
* do not flag index signatures as a control flow container

* add tests and baselines
2022-04-07 13:29:07 -07:00
Wesley Wigham
4d2fb5407c Preserve the distributivity of inlined conditional types in declaration emit (#48592) 2022-04-06 17:21:46 -07:00
Wesley Wigham
94d33ba85d Ensure late painted statements are only transformed once, so inner substitutions are consistently read (#48558)
* Ensure late painted statements are only transformed once, so inner substitutions are consistently read

* PR suggestion

* Fix lint
2022-04-06 16:36:42 -07:00
Mateusz Burzyński
702bc5222b Add additional tests for intra expression inference (#48584) 2022-04-06 16:17:53 -07:00