Commit graph

23273 commits

Author SHA1 Message Date
Oleksandr T e961916217
fix(42368): omit converting jsx spread attributes to Object.assign for ES2018 and up (#42554) 2021-02-18 17:06:08 -08:00
ExE Boss 0723904bfb
feat(lib/es2021): Add type parameter to FinalizationRegistry (#42274)
* feat(lib/es2021): Add type parameter to `FinalizationRegistry`

* test(lib/es2021): Add test for generic `FinalizationRegistry`
2021-02-18 16:43:36 -08:00
ZYSzys 9950b6e596
Improve error messages for computed class property names (#42675) 2021-02-18 15:58:18 -08:00
Titian Cernicova-Dragomir a2ed469022
Fix for crash when using ca call expression on private identifier coming from an any typed variable. (GH #42860) (#42861) 2021-02-18 13:54:10 -08:00
pushkine d2737ecd17
Update scriptInfo.ts (#42855) 2021-02-18 10:52:58 -08:00
Andrew Branch 1fd71478f9
Fix duplicate auto-import completions (#42850)
* Fix duplicate auto-import completions

* Update src/services/completions.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
2021-02-18 10:06:37 -08:00
Nathan Shively-Sanders 3d7ec8aab2
Improve @template lookup and resilience (#42851)
* Improve @template lookup and resilience

1. @template parsing may produce a template tag with a type parameter
whose name is the missing identifier. These tags should be skipped
in the checker because they receive an error in the parser.
2. The fix in #37819 was incorrect; there's no such thing as a type
parameter declared on a variable declaration. Instead, there needs to be a type
parameter declared on a jsdoc comment, because that's the scope for tags
like `@return` and `@typedef`.

There are 3 tests because either fix (1) and (2) fix the first test's
failure, but both are required to fix the last two tests' failures.

* remove containsParseError call
2021-02-17 17:21:17 -08:00
Josh Goldberg c3d7a56e90
Specified diagnostic for iterating known array type without --downlevelIteration (#40070)
* Specified error message for iterating known array types without --downlevelIteration

* Added extra target info to diagnostic

* NodeList too, a classic

* PR feedback: invert to allowsStrings; required param

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-02-17 17:12:32 -08:00
Oleksandr T 7fca9267e6
fix(41740): disallow renaming/exclude from references default keyword (#41947) 2021-02-17 17:07:31 -08:00
Amin Pakseresht 20ce292484
Provide completion for partial expression on closing jsx tags (#42029)
* Provide completion for partial expression on closing jsx tags

* Add more cases and cover opening tag is parent parent of location

* Fix code style indentation

* Add some more notes

* Guarding null pointer

* Guarding null pointer 2

* PR reviews & adjustments 1

* Fix typos

* Better namings

* Remove failing test-case

* PR reviews & adjustments 2 - new approach

* More comments

* More comments 2

* PR reviews & adjustments 3

* Revert previous test-case file changes

* Write explicit completions from ranges

* PR reviews & adjustments 4 - adding exact entry

* Add another missing test-case

* Find jsx closing element by findAncestor

* Walk up till find jsx closing element

* Add one more test-case

* PR reviews & adjustments 4 - Pattern matching to get jsx closing element

* Minor change

* Linting fixes
2021-02-17 17:06:13 -08:00
Ryan Cavanaugh f5618562ab
Check for missing type parameter names in JSDoc template tags (#42017)
* Check for missing type parameter names in JSDoc template tags

Fixes #36692

* Update baselines
2021-02-17 16:54:56 -08:00
Anders Hejlsberg 412ecbc291
Reduce void | undefined only in conjunction with subtype reduction (#42846)
* Reduce void | undefined only in conjunction with subtype reduction

* Accept new baselines

* Add regression test
2021-02-17 14:48:07 -10:00
Jesse Trinity d640313ff2
Expand extractSymbol ranges (#42770)
* allow partial selections of node ranges

* separate tests for better failure investigation

* gate span expansion behind invoked command

* add invoked test

* comment wording

* for test
2021-02-17 12:55:12 -08:00
Chakib Ljazouli 3fe05c8c81
fix(37578): Deprecate variable name AllowQualifedNameInPlaceOfIdentifier (#38726)
* Change variable name AllowQualifedNameInPlaceOfIdentifier to AllowQualifiedNameInPlaceOfIdentifier

* Change deleting AllowQualifedNameInPlaceOfIdentifier to deprecating it instead.

* Fix failing tests

* Replace old value
2021-02-16 16:07:44 -08:00
Long Ho 3910d9ede2
fix: fix RelativeTimeFormat type definition (#39661)
* fix: fix RelativeTimeFormat type definition
Changes:
1. Change BCP47LanguageTag to UnicodeBCP47LocaleIdentifier: Those mean 2
different things. BCP47LangTag allows _ as separator while UTS35
doesn't. It also allows grandfathered locales and UTS35 doesn't.

2. Combine RelativeTimeFormat interface and const declaration into a
single class. The old way of declaring as `interface` & `const` permits
calling `Intl.RelativeTimeFormat` without `new` which is no longer
possible after `Intl.DateTimeFormat` & `Intl.NumberFormat`. The spec
explicitly forbids it in
http://ecma-international.org/ecma-402/7.0/index.html#relativetimeformat-objects
where:

> If NewTarget is undefined, throw a TypeError exception.

Intl.RelativeTimeFormat is also extensible per spec. This is closer to a
`class` than the current declaration.

* address feedbacks
2021-02-16 15:56:56 -08:00
Wenlu Wang d6a32e31ae
Fix import fix on react or react dev (#41950) 2021-02-16 10:28:48 -08:00
Jack Works bb8b9db9f7 Add error for missing await in conditionals 2021-02-16 12:00:41 -05:00
Oleksandr T e5294b4d3c
fix(42519): fix infer function return type quick fix with arrow functions without parens (#42532) 2021-02-12 14:38:29 -08:00
Sheetal Nandi e98f6b07ab
Refactor project references and source map tsserver tests so they are inline for easy editing (#42782) 2021-02-12 14:32:23 -08:00
Nathan Shively-Sanders 5deb676b3a
No did-you-mean-to-call error on casts Part 2 (#42779)
* No did-you-mean-to-call error on casts

I chose to do the ad-hoc check rather than yet another tree walk.

1. It's faster to run and easier to read.
2. This error came from looking at real code. It happened twice, so I
think the best estimate for other uses that happened zero times is in
fact zero.
3. I couldn't think of other places to put the cast, given the
restrictions on `testedNode` just before the new code.

* Skip parentheses
2021-02-12 10:07:59 -08:00
Nathan Shively-Sanders f2bcb2101b
No did-you-mean-to-call error on casts (#42626)
I chose to do the ad-hoc check rather than yet another tree walk.

1. It's faster to run and easier to read.
2. This error came from looking at real code. It happened twice, so I
think the best estimate for other uses that happened zero times is in
fact zero.
3. I couldn't think of other places to put the cast, given the
restrictions on `testedNode` just before the new code.
2021-02-12 09:36:55 -08:00
Oleksandr T ff5ae3561f
feat(42735): add single line comments to selection ranges (#42763) 2021-02-11 17:14:55 -08:00
Oleksandr T 475036950e
fix(42133): fix instantiated undefined type from JS initializer (#42662) 2021-02-11 17:07:14 -08:00
Eli Barzilay c7bac6f2e6 Avoid getting undefined callSignatures/constructSignatures in getPropertyOfType
e350c357 (#40228) introduced a subtle bug: it switched the flags to an
alias, dropping `SymbolFlags.Property` --- and that makes
`symbolIsValue()` get to the `resolveAlias(symbol)` call, which leads to
`getPropertyOfType()` with`resolved.callSignatures`+`constructSignatures`
being `undefined`.  So initialize them in `setStructuredTypeMembers`
before calling `getNamedMembers()`.

Fixes #42350
2021-02-11 18:56:47 -05:00
Masato Urai a3ead92046 Improve error message for overload that takes spread arguments
The original error message on the last line I have added to in
functionParameterArityMismatch.ts was

    No overload expects 5 arguments, but overloads do exist that expect
    either 4 or Infinity arguments.

even if we do not define a function that takes Infinity arguments.

This PR changes it to this:

    Expected 0-6 arguments, but got 5 or more.

I feel it is still a bit strange but much more understandable.

Fixes #42418
2021-02-11 16:49:21 -05:00
Eli Barzilay 4fc9c8446d Refactor the tracing namespace organization
Also changes the `tracingEnabled.Mode.*` enum to a string union.
2021-02-11 16:08:35 -05:00
Oleksandr T b7922147d3
fix(42714): do not show inferFunctionReturnType QF on function body (#42737) 2021-02-11 10:46:48 -08:00
Daniel Rosenwasser 94747aa4e1
Bump version to 4.3. (#42728) 2021-02-09 17:07:28 -08:00
Sheetal Nandi 5280ba400c
Handle if plugin doesnt specify name (#42717)
Fixes microsoft/vscode#116219
2021-02-09 15:23:29 -08:00
Orta Therox 8c5fa5cc91
Revert assignability cases in getNarrowedType (#42231)
* Revert subtype narrowing changes from readonly array PRs

* Adds a test for the change

* More baselines
2021-02-09 15:03:11 -08:00
Jesse Trinity 1b19af0f14
Refactor params for interface (#42652)
* apply refactor to interface methods

* handle calls

* no available refactors for union type

* add tests

* Update src/services/refactors/convertParamsToDestructuredObject.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* address comments

* Update src/services/refactors/convertParamsToDestructuredObject.ts

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>

* Update src/services/refactors/convertParamsToDestructuredObject.ts

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

Co-authored-by: Daniel Rosenwasser <DanielRosenwasser@users.noreply.github.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2021-02-09 13:30:31 -08:00
Daniel Rosenwasser 664ed17ebd
Allow only package names as plugin names (#42713)
* Allow only package names as plugin names

* Remove extra argument following merge from master branch.

* kipped -> Skipped

Co-authored-by: Sheetal Nandi <shkamat@microsoft.com>
2021-02-09 11:30:09 -08:00
Eli Barzilay fe2899c2ac Use a 10ms sampling frequency to filter tracing dumps
Currently hard-wired to 10ms, can be made configurable if needed later.
2021-02-08 17:01:45 -05:00
Eli Barzilay f462576ac2 Re-do tracing initialization and tests around calls
Make `tracing` either `undefined` or the same namespace as before.
Switching all calls to `tracing?.___` means that there is no cost for
a call or the arguments when tracing is not used.  Comparing two runs
without tracing (27 runs, drop 5+5, avg rest) I get:

    master:
      42.59s user 1.00s system 165% cpu 26.372 total
    changed:
      42.01s user 0.982 system 165% cpu 26.039 total

(Makes it all private, so no api changes.)
2021-02-08 15:41:35 -05:00
Oleksandr T 60a6240210
feat(42637): add generateReturn option to UserPreferences (#42642) 2021-02-05 15:24:48 -08:00
Wesley Wigham 4c43e09c9e
Add fallback error locations for nameless declarations, better class error locations (#42585) 2021-02-05 12:07:14 -08:00
Nathan Shively-Sanders aba932aefa
Create synthetic exports symbol for commonjs module (#42655)
* Commonjs module:create synthetic exports symbol

Previously, the `module` identifier in commonjs modules got a synthetic
type with a single property `exports`. The exports property reused the
file's symbol, which, for a module file, gives the correct exported
properties.

However, the name of this symbol was still the filename of the file, not
`exports`. This PR creates a synthetic symbol for `exports` by copying
in a similar way to esModuleInterop's `default` symbol in
`resolveESModuleSymbol` (although the intent there is to strip off
signatures from the symbol).

* correct parent of synthetic symbol
2021-02-05 10:56:03 -08:00
Andrew Branch 79ed041b6a
Fix Format Selection on JSDoc comments (#42411) 2021-02-05 10:37:47 -08:00
Nathan Shively-Sanders f1583f08a0
Signature help turns off current-parameter display for non-trailing rest parameters (#42592)
* Signature help: support non-trailing rest parameters

In signature help, the first rest parameter will always be the *last*
'current' parameter (disregarding types). Previously, the signature help
current-parameter highlight was only correct for trailing rest
parameters. However, with tuple types, you can now create non-trailing
rest parameters. This PR now correctly highlights non-trailing rest
parameters as the last 'current' parameter.

For example, `names` should be the current parameter in all the calls
below:

```ts
declare function loading(...args: [...names: string[], allCaps: boolean, extra: boolean]): void;

leading(/**/
leading('one', /**/
leading('one', 'two', /**/
```

And, because signature help doesn't do real overload resolution, `names`
is also the current parameter for other calls:

```ts
leading(1, 2, 3, 'ill-typed', /**/
leading('fine', true, /**/
```

* Change 'variadic' to 'rest'

* fix missed rename

* use single, original tuple instead

* Revert "use single, original tuple instead"

This reverts commit f0896f32ea.

* Improve sig help of trailing rest too

1. Trailing rest keeps highlight at end instead of going off the end.
2. Non-trailing rest disable highlight entirely (by putting the index
one past the end).

* update API baselines
2021-02-05 09:37:28 -08:00
Wesley Wigham 19db9ad675
Swapping the quote style of a string for completions should swap _all_ quotes in the string (#42650) 2021-02-04 13:56:34 -08:00
Wesley Wigham f569aa3832
Use a (hopefully) more efficient regex for matching jquery in the safelist (#42653) 2021-02-04 13:53:05 -08:00
Wesley Wigham 62bc8bec4e
Replace _all_ tabs in pretty output, not just the first on each line (#42649) 2021-02-04 13:25:53 -08:00
Wesley Wigham be18057792
Add check for no match into fs watch rename event handler (#42651) 2021-02-04 13:20:38 -08:00
Anders Hejlsberg ab2729a99b
Smarter subtype reduction in union types (#42353)
* Exclude primitive types from union subtype reduction in most cases

* Accept new baselines

* Minor fixes

* Less aggressive checking of assertion function calls that don't affect control flow

* Accept new baselines
2021-02-04 11:18:30 -10:00
Andrew Branch 258be217a6
Fix completions crash on transient exported property named 'default' (#42583)
* Fix completions crash on transient exported property named default

* Revert simplification, both conditions were needed
2021-02-04 10:22:15 -08:00
Oleksandr T 4c118ae67b
fix(39022): wrap export references UnaryExpression to ParenthesizedExpression (#41156) 2021-02-03 18:26:33 -08:00
Anders Hejlsberg e2318217fb
Strip nullable types from 'this' type in inference with optional chain calls (#42536)
* Properly strip nullable types from this type in optional chain calls

* Add regression test
2021-02-03 13:50:23 -10:00
Daniel Rosenwasser cce4bfbc7c
Revert changes for template literal types, keeping tests. (#42588)
* Revert changes for template literal types, keeping tests.

* Update Baselines and/or Applied Lint Fixes

Co-authored-by: TypeScript Bot <typescriptbot@microsoft.com>
2021-02-03 14:49:03 -08:00
Daniel Rosenwasser 654975481f
Use spaces instead of non-breaking spaces, narrow non-breaking spaces. (#42500) 2021-02-03 14:29:42 -08:00
Sheetal Nandi c3e132da59
Keep extended config's raw file, include, exclude relative to itself and correct it when setting extending options (#42544)
* Test when config file extends is incorrectly computed
Test for #40720

* Keep extended config's raw file, include, exclude relative to itself and correct it when setting extending options
Fixes #40720
2021-02-03 11:09:06 -08:00