Commit Graph

11510 Commits

Author SHA1 Message Date
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
a2b785b6cb Limit type argument inference from binding patterns (#49086)
* WIP

* Don’t widen literals based on bogus contextual type instantiation

* Split tests

* Skip unnecessary inference pass

* Accept test baselines

* Fix stray edit

* Fix type mapper combination

* Revert src/ of 7dc1952a82

* Make empty binding pattern provide no contextual type

* Add missed baseline
2022-05-24 09:05:34 -07:00
Wesley Wigham
194a2aea0d Key validity of import=require in module: node off of module and not target (#49222) 2022-05-24 03:33:23 -07:00
Nathan Shively-Sanders
006ae339bf Add es2018.intl ref to es2020.intl (#49152)
* Add es2018.intl ref to es2020.intl

es2020.intl refers to NumberFormatPartTypes declared in es2018.intl
as of #46508.

I'm not sure how to test this; it repros on Definitely Typed in
types/ndarray, but when I copy the same files into a compiler test it
passes without a problem.

* Add a test that shows the change works

It doesn't actually show that the original bug has been fixed,
though.
2022-05-20 11:04:34 -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
Andrew Branch
e56a067801 Fix uncalled function check usage detection for && expressions (#49157) 2022-05-18 13:58:06 -07:00
Oleksandr T
755d5ccad6 fix confused comment (#49094) 2022-05-16 15:26:26 -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
Nathan Shively-Sanders
95731f0397 No errors on apparent type of bigint or symbol, even for recent targets (#49104)
* Remove bigint from Object.freeze in es5.d.ts

`BigInt` isn't resolved whenever `lib < es2020`, but it's not an error
when `target < es2020`. I have a few ideas for improving this situation
but for the RC I'm going to remove `bigint` from Object.freeze's
signature.

* Update other baselines

* No errors for missing apparent type of bigint,symbol for any target

* Update test text
2022-05-16 09:14:00 -07:00
Daniel Rosenwasser
0414deeaaf Merge pull request #48954 from a-tarasyuk/fix/48948
fix(48948): constructor can't be the name of class accessors and generators
2022-05-13 12:20:45 -07:00
Oleksandr T
d8ebeebc59 move tests to conformance/salsa from compiler 2022-05-13 09:24:33 +03:00
Jack Works
b689cd0aa9 feat: support error when comparing with object/array literals (#45978)
* feat: support error when comparing with object/array literals

* chore: include regexp, function and class literal

* chore: include regexp, function and class literal

* test: update baseline

* fix: baseline
2022-05-12 15:45:22 -07:00
Oleksandr T
c300fea325 fix(7410): allow using JSXElement as JSXAttributeValue (#47994) 2022-05-11 14:47:35 -07:00
Andrew Branch
5c2febfe02 Allow referencing type-only exports as namespace members in ImportTypes and TypeQueries (#49056)
* Allow referencing type-only exports as namespace members in ImportTypes and TypeQueries

* Add extra test case

* ;; -> ;

* undefined -> false

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2022-05-11 11:44:59 -07:00
Daniel Rosenwasser
3e24f14871 Merge pull request #49029 from DavidSouther/fix/44466-contextual-keyword-assertion
fix(44466): Fixes parsing contextual keyword casts as arrow functions
2022-05-10 16:37:49 -07:00
Andrew Branch
08b1cce595 Add regression test for #46192 (#49057) 2022-05-10 16:27:46 -07:00
Mateusz Burzyński
9236e39374 Fixed an issue with contextual type for intersection properties (#48668)
* Add a failing test case for contextual type not provided for functions comming from a property with intersection type

* Fixed an issue with contextual type for intersection properties

* Fixed how type of a property of a contextual type is being computed when intersections with indexers are used
2022-05-09 16:03:48 -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
Ron Buckton
e2bd89b309 Report error for invalid 'this' type during 'await' (#48946) 2022-05-09 13:58:36 -07:00
Andrew Branch
f3f0a3f394 Fix module specifier generation crash from typesVersions (#49035) 2022-05-09 12:48:24 -07:00
Wesley Wigham
f84ec3e8b4 Fix type parameter comparability to consistently allow comparisons on unconstrained type parameters (#48861)
* Fix type parameter comparability to consistently allow comparisons on unconstrained type parameters

* Less elaboration, non-strict-mode fix
2022-05-09 12:22:00 -07:00
David Souther
958adfc9d8 Use all modifiers test 2022-05-09 10:41:02 -07:00
David Souther
3dd9ef43ce fix(44466): Fixes parsing contextual keyword casts as arrow functions 2022-05-09 10:22:22 -07:00
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
Oleksandr T
538d6ce828 fix(48948): disallow constructor name in class accessors and generators 2022-05-04 21:04:23 +03: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