Commit Graph

10297 Commits

Author SHA1 Message Date
Alexander T
48c19eebaf fix(25155): add space before optional parameters/properties (#38798) 2020-07-08 13:38:15 -07:00
Wesley Wigham
dd2b2447d0 Add regression test for #38834 (#39479) 2020-07-08 13:32:15 -07:00
Sheetal Nandi
0f86c04af3 Fixes searches for symbols exported using export * as (#39507)
Fixes #39006
2020-07-08 13:31:21 -07:00
Alexander T
ebac7ec08f fix(39421): omit prefix text for rest binding element (#39433) 2020-07-08 13:25:28 -07:00
Alexander T
8795458d6d fix(39440): show QF for abstract classes with methods which include 'this' parameter (#39465) 2020-07-08 12:36:42 -07:00
Nathan Shively-Sanders
53a756ea63 Type this in more constructor functions (#39447)
* Type `this` in more constructor functions

Previously,  `this: this` in constructor functions only when there was
an explicit `@constructor` tag on the function. Now, `this: this` for
any function that's known to be a constructor function.

This improves completions inside constructor functions; also note that
previously the compiler *did* type `this: this` inside methods of constructor
functions, so this fix makes us more consistent. This is reflected in
the large number of baselines that improve.

The fix is a simple switch to `isJSConstructor`, which is the standard
way to detect constructor functions. I'm not sure why the original PR
didn't use this method.

I remember discussing this limitation in the original bug, #25979, and
I guess I decided that it made sense. But I was heavily primed by the bug's
framing of the problem in terms of `noImplicitThis`, which *should*
require an explicit `@constructor` tag.

With better typing comes better detection of `@readonly` assignment; I
had to fix the readonly detection code to use `isJSConstructor` as well.

* Remove `Add @class tag` fix for noImplicitThis.

The new rules mean that it never applies. It's possible that it should
apply to functions like

```js
function f() {
  this.init()
}
```

In which `init` is never defined, but I think this program is incomplete
enough that not offering the fix is fine.

* Fix precedence of `@this`

Previously, both `@class` and `@this` in a jsdoc would cause the `@this`
annotation to be ignored. This became a worse problem with this PR,
because `this` is correctly typed even without the annotation.

This commit makes sure that `@this` is checked first and used if
present.
2020-07-08 08:44:17 -07:00
Anders Hejlsberg
8c6b85835f Properly handle rest parameters in function declarations with @type annotations (#39473)
* Properly handle rest parameters in function declarations with @type annotations

* Add tests
2020-07-07 16:35:37 -07:00
Wesley Wigham
d2b32b422f Ensure type/namespaceish statics are included in the list of namespace merge members (#38920)
* Ensure type/namespaceish statics are included in the list of namespace merge members

* Simplit into two lines

* Update baseline post-merge
2020-07-07 16:28:09 -07:00
Wesley Wigham
4f375552b5 Fix crash in decorator metadata calculation when serializing template literal type nodes (#39481) 2020-07-07 15:29:52 -07:00
Wesley Wigham
62b4377acf Fix test semantic merge conflict between #39348 and #39130 (#39478) 2020-07-07 14:30:58 -07:00
Ron Buckton
b100680a3e Fix for relating covered discriminants in unions (#39393) 2020-07-07 13:11:55 -07:00
Andrew Branch
0c75021860 Process type nodes in codefixes/refactors for auto-imports recursively (#39130)
* Process type nodes for auto-imports recursively

* Rename function
2020-07-07 13:11:23 -07:00
Nathan Shively-Sanders
1814e2a5c4 Mark @typedef as a type declaration (#39468)
* Mark @typedef as a type declaration

This is only important right now for marking uses of deprecated tags due
to the way that deprecated type references are computed. But I'm
surprised it hasn't caused problems elsewhere.

Fixes #39466

* Also mark @callback and @enum

Requires making name lookup in isTypeDeclarationName smarter, but this
is only used by services, so shouldn't be too performance sensitive.
2020-07-07 10:37:52 -07:00
Alexander T
6b493f2048 fix(23871): change insertNodeAfter to replaceNode to avoid extra newlines (#38045) 2020-07-07 12:54:03 -04:00
Orta Therox
6ebd73c84f Don't narrow against unions of constructor functions with instanceof (#38099)
* WIP

* Only narrows when the union is not all constructors
2020-07-07 11:34:10 -04:00
Nathan Shively-Sanders
9a65658b28 Parse *= separately in types (#39457)
* Parse *= separately in types

Previously, when the scanner produced `*=` as a single token, the type
parser ran special-case code to produce an "optional all type", which
only makes sense when the `=` really should be attached to the `*`. This
is often not the case.

The correct solution, which I missed when I first wrote this code, is to
have the scanner go back and produce a separate `=` token, which is what
this PR does.

* add test from #38551

* we ❤️ semicolons
2020-07-07 08:30:42 -07:00
Alexander T
2a92a6ea91 fix(39332): handle quotes preference in interface method signatures (#39348) 2020-07-06 17:00:35 -07:00
Wenlu Wang
453365284c Avoid check for union keys (#39314) 2020-07-06 15:01:05 -07:00
Nathan Shively-Sanders
0d84f210b7 In JS, assignment to void 0 isn't a declaration (#39452)
Previously, property assignments with `void 0` initialisers were treated
like any other values. But this causes us to choke when checking our own
commonjs emit. This is something that happens by mistake a fair amount,
so this PR goes back to treating these assignments as normal
assignments.

This should allow us to check our own emit in loose cases without
harming other code bases, since `void 0` is rarely written by hand.

Note that other errors still happen: noImplicitAny forbids
accessing undeclared properties on object literals, and strictNullChecks
forbids assigning `undefined` to properties with a different type.
However, this change is enough to unblock compilation with
`strictNullChecks: false`.
2020-07-06 14:00:12 -07:00
Daniel Rosenwasser
77bf2045d8 Merge pull request #39379 from a-tarasyuk/bug/39346
fix(39346): Intelligent code completion not working in child class with composited base interface
2020-07-06 11:59:30 -07:00
ShuiRuTian
f29e03eea5 autocomplete works for const assertion. (#39412)
* fix 39384

* add test
2020-07-06 08:49:50 -04:00
Anders Hejlsberg
2fe2f88047 Fix control flow analysis for nested try-catch-finally statements (#39399)
* Fix control flow analysis for nested try-catch-finally statements

* Add tests
2020-07-03 09:51:01 -07:00
Nathan Shively-Sanders
93ccc17658 Node-based @deprecated checks (#39323)
* Node-based @deprecated checks

Switch the checker to syntactic checks for `@deprecated` on
declarations. This requires a bit more checking of declarations in the
checker at times, but it

1. Gets rid of work, and a symbol flag, in the binder.
2. Skips work in the checker unless there is a `@deprecated` tag.
3. Makes it fairly simple to only issue errors on particular signatures
   of overloaded functions.

* remove in-progress comment

* remove unused isTypeDeclaration

* ❤️ lint

* support jsx and tagged template functions

* Support decorators too
2020-07-02 14:09:59 -07:00
Ron Buckton
652a1c5950 Emit fallback for decorator metadata for type only imports (#39337) 2020-07-02 11:39:27 -07:00
Ron Buckton
8eba362a01 Fix for relating covered discriminants in unions 2020-07-02 11:09:14 -07:00
Alexander T
d137e4a23b fix(39346): show completion in inherited classes from the composited base interface 2020-07-02 11:40:17 +03:00
Nathan Shively-Sanders
df5981319f Fix crash on completion in jsdoc namepath (#39347)
contextToken may be undefined, so the isAssertionExpression call in
filterGlobalCompletion needs to check for undefined.
2020-06-30 15:53:13 -07:00
Andrew Branch
e2c5a90cc3 Disable signature help on unresolved bare identifiers; add more declaration info on other unresolved calls (#39352)
* Disable signature help on unresolved bare identifiers; add more declaration info on unresolvedproperty access

* Remove stray ts-ignore
2020-06-30 14:25:27 -07:00
Wesley Wigham
ff1f449b99 Fix type of computed name following spread (#39319) 2020-06-30 13:37:59 -07:00
Alexander T
8b6a88700e fix(32297): add quick-fix action to delete parameter destructuring elements (#38764) 2020-06-30 11:44:47 -07:00
Daniel Rosenwasser
1bbd5ef36b Merge pull request #38754 from a-tarasyuk/feat/25259
feat(25259): Better error report for equals instead of colon in object literals
2020-06-30 01:56:26 -07:00
Alexander T
21a26ca08a feat(25259): add better error to report for equals instead of the colon in object literals 2020-06-30 10:33:56 +03:00
Daniel Rosenwasser
619658bd44 Merge pull request #39109 from Kingwl/lambda_span
Add outlining spans for call expression or arrow body
2020-06-29 23:33:04 -07:00
Anders Hejlsberg
784396ce95 Infer implied arity before inferring from 'this' argument (#39328)
* Infer implied arity before inferring from 'this' argument

* Add regression test
2020-06-29 17:38:41 -07:00
Anders Hejlsberg
b448540644 No speculative inferences for variadic tuples (#39281)
* No speculative inferences to types like [...T, U?]

* Add tests
2020-06-29 15:24:32 -07:00
Daniel Rosenwasser
57dd722ab6 Merge pull request #38776 from a-tarasyuk/bug/29890
fix(29890): JSX: "extract to constant" generates invalid code
2020-06-29 14:09:52 -07:00
Wesley Wigham
99bec5067b Use mapped rest type member when expanding rest parameter names (#39317)
* Use mapped rest type member when expanding rest parameter names

* Add test for #39228 which is also fixed by parameters having unique names
2020-06-29 12:30:23 -07:00
Alexander T
ee5c3fa57d fix(39047): handle extra spaces after the catch statement (#39306) 2020-06-29 10:10:44 -07:00
Andrew Branch
58ed610ef1 Allow distinct string enum members with identical property names to form unions in mapped types (#39101) 2020-06-29 10:08:17 -07:00
Alexander T
c75af697af fix(29890): wrap variable/method/property to jsx expression 2020-06-28 10:51:11 +03:00
Andrew Branch
3d22a4fd72 Preserve newlines between try/catch/finally, if/else, do/while (#39280)
* Preserve newlines between try/catch, if/else, do/while

* Update baselines
2020-06-26 14:48:19 -07:00
ShuiRuTian
4601a786aa not narrow static property without type annotation in constructor. (#39252)
* fix #39226

* fix lint.
2020-06-26 11:08:35 -07:00
Alexander T
95690c0aca fix(38840): omit completions for a spread like argument in a function definition (#38897) 2020-06-26 09:38:05 -07:00
Alexander T
59f80970d9 fix(38785): include in NavigationBar child items from default exported functions (#38915) 2020-06-26 09:35:27 -07:00
Wenlu Wang
6b4d0bff40 Avoid effect of element access expression (#39174)
* Avoid effect of element access expression

* Avoid unnecessary copy

* Add more tests
2020-06-25 17:38:05 -07:00
Anders Hejlsberg
ee4aee0531 Handle 'keyof' for generic tuple types (#39218)
* Handle keyof T where T is generic tuple type

* Add tests

* Accept new baselines

* Address CR feedback

* Accept new baselines
2020-06-25 13:49:20 -07:00
Anders Hejlsberg
8df85b5cae Disable unsound T[K] rule in subtype relations (#39249)
* Disable unsound T[K] rule in subtype relations

* Add test
2020-06-25 10:22:48 -07:00
Wesley Wigham
a3ee09ddc9 Handle recursive type references up to a certain level of expansion in inference (#38011)
* Handle recursive type references up to a certain level of expansion in inference

* Move object cases into the same conditional branch
2020-06-24 14:24:34 -07:00
Wesley Wigham
d1ebf126d2 Do not consider binding patterns in contextual types for return type inference where all the signature type parameters have defaults (#39081) 2020-06-24 13:45:17 -07:00
Wesley Wigham
7893c9fc7e Do not add reexported names to the exportSpecifiers list of moduleinfo (#39213) 2020-06-23 17:56:44 -07:00