Commit Graph

11633 Commits

Author SHA1 Message Date
magic-akari
abc2a350e6 Fix System module export import = (#49788)
* Add more SystemJS test case

* Fix System module `export import =`

* Update test case
2022-08-09 16:31:02 -07:00
Oleksandr T
f70cb769ef feat(49928): Provide quick fix for a missing callback function (#49930)
* feat(49928): provide quick fix for a missing callback function

* remove addFunctionDeclarationFromSignature. fix formatting

* add tests
2022-08-09 15:28:03 -07:00
Oleksandr T
19e2a310c0 feat(49834): Suggestion: filter enum member ids from their own jsdocs (#49843)
* feat(49834): omit self-referenced enum declaration in JsDoc

* change code style
2022-08-09 15:02:45 -07:00
Mateusz Burzyński
0e17dc7769 Fixed a false positive related to binding patterns and spread expressions (#49684)
* Fixed a false positive related to binding patterns and spread expressions

* Improve ancestor lookup when checking if an expression is spread into an object

* Fixed ancestor lookup for more node types

* Remove equality check for contextual types

* Reformat code

* Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal

* Revert "Use `isWithinSpreadAssignment` flag + `objectsWithinSpread` cache instead of ancestor traversal"

This reverts commit be387e3bbf.

* Expand on the existing comment
2022-08-08 17:01:50 -07:00
Gabriela Araujo Britto
bdb8514b82 Fix contextual typing on yield and return expressions in generator function (#49736)
* add tests and initial fix

* fix contextual return type in generator funcs

* fix return statement contextual typing

* filter using getiterationtypeofgeneratorfunctionreturntype

* update baselines
2022-08-05 11:24:43 -07:00
Oleksandr T
a44354af7c fix(50188): omit QF on function arguments (#50189) 2022-08-04 17:52:09 -07:00
Andrew Branch
7afd14f263 Update error messages for CJS imports resolving to ES modules (#50088)
* Update error messages for CJS imports resolving to ES modules

* Update error message

* Use package scope from source file

* Update baselines

* Issue error for JSX/TSX files

* Switch from related info to message chain
2022-08-04 16:58:13 -07:00
Ron Buckton
6bbe6d67d1 Fix return value and error reporting for getIterationTypesOfMethod (#50146) 2022-08-03 19:07:29 -04:00
Ron Buckton
d6d26430c7 Add rule to auto-paren optional chain in normal prop or element access (#50156) 2022-08-03 17:17:26 -04:00
Andrew Branch
c82c9a9744 Fix bugs in module specifier generation with paths/typesVersions (#49792)
* Write a test and a huge comment

* Finish fixing everything

* Clean up comment

* Remove obsolete comment

* Fix comment trailing off

* Optimize to hit the file system much less
2022-08-03 13:58:15 -07:00
Oleksandr T
59c91f6ce9 fix(50077): skip convertOverloadListToSingleSignature refactoring if position is in function body (#50093) 2022-08-03 13:56:42 -07:00
Jack Bates
040c1216ff Better typings for Promise.resolve(), like #31117 (#33074)
* Better typings for Promise.resolve(), like #31117

* Add tests

* Update to Awaited<T>

* Fix issue with Awaited affecting jQuery, additional tests

Co-authored-by: Ron Buckton <ron.buckton@microsoft.com>
2022-08-02 13:39:50 -04:00
Oleksandr T
c0072aad80 fix(49935): omit parentheses in the operand of the unary expression (#50111) 2022-08-01 17:22:45 -04:00
Ron Buckton
55f2c0cb49 No synthetic Awaited for unconstrained type when not a type variable (#50100) 2022-08-01 17:19:15 -04:00
Nathan Shively-Sanders
427d43691a Improve import type support for commonjs exports (#49745)
* Improve import type support for commonjs exports

This PR makes getTypeFromImportTypeNode a little more like
getExternalModuleMember: for JS files, it now uses both
`getTypeOfSymbol` and `getExportsOfSymbol`, and uses whichever one
returns a symbol. This allows using arbitrary properties of a CJS export=
as types in JSDoc; previously a special case in the binder enabled only
CJS export= where all properties were shorthand assignments.

Fixes #49195

* Add js types/value test case

* Improve binding of CJS property assignments

1. Bind property assignments same as shorthand property assignments in
module.exports object literal assignments.
2. Bind all such assignments, even if the object literal contains
non-property assignments. This is different from before, and it requires
slightly smarter code to prefer aliases when checking CJS imports.

* Remove new binder code

Just include the original fix

* revert missed type in binder
2022-08-01 10:57:38 -07:00
Oleksandr T
ae7d2325e9 fix(49869): throw an error on optional binding pattern parameter in JavaScript (#50094) 2022-07-29 16:05:34 -07:00
Ron Buckton
88a1e3a1dd Transform decorators that reference private names into a 'static {}' block (#50074) 2022-07-29 15:29:48 -04:00
Mateusz Burzyński
5374fd924e Add an additional test for favoring the asserted type in type predicate narrowing (#50065)
* Add an additional test for favoring the asserted type in type predicate narrowing

* Add requested test cases
2022-07-29 12:12:33 -07:00
Zzzen
1490037f17 fix dts generation of jsdoc (#49904) 2022-07-28 17:44:23 -07:00
Oleksandr T
949fffb1e0 feat(47983): Negative tuple index access should not be allowed (#49901)
* feat(47983): disallow negative integers for indexing tuple

* change error message

* add additional tests
2022-07-28 14:22:13 -07:00
Andrew Branch
b7355e30af Fix trailing formatting edit when range ends mid-token (#50082) 2022-07-28 12:11:22 -07:00
Oleksandr T
94bb950008 feat(49358): use filename based on exported name (#49875) 2022-07-27 15:41:31 -07:00
Sheetal Nandi
5b0eea48e9 Report error only on local declaration with additional related information (#49746)
* Add test where the errors are reported in different file
Test for #49739

* Report error only on local declaration with additional related information
Fixes #49739

* Handle existing tests
2022-07-27 15:31:45 -07:00
Jake Bailey
8d0c72d5e0 Normalize effective constraint intersection before checking if source is a part of it (#49956) 2022-07-27 10:06:01 -07:00
Josh Goldberg
ebd42abf95 Account for type parameters in missing function codefix (#49727)
* Account for type parameters in missing function codefix

* Apply suggestions from code review

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

* WIP

* Synthesize new type parameters instead of deep unions and intersections

* Pass along type parameter constraints

* E.T. phone home

* Clean up comments just a bit

* Only widen the instance type sometimes

Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-07-26 15:22:19 -07:00
Jake Bailey
3afe2d654e Resolve parsingContextErrors TODO (#50011)
* Add a test with broken code

* Resolve TODO
2022-07-26 08:59:06 -07:00
Oleksandr T
bcd22b47d2 fix(50048): remove token name from id (#50051) 2022-07-26 01:13:04 -07:00
Ron Buckton
12dbdf03b1 Parse parameter decorators outside of Await context when appropriate (#50040) 2022-07-25 17:17:27 -04:00
Anders Hejlsberg
4026c6fd80 Properly handle null and undefined in getCommonSupertype (#50021)
* Properly handle null and undefined in getCommonSupertype

* Add tests

* Add more tests
2022-07-24 08:09:14 -07:00
Jake Bailey
966e732ed4 Remove uses of visitNodes and visitNode in visitEachChild (#49992) 2022-07-22 19:35:39 -07:00
Andrew Branch
6aefc1dcea More fixes to uncalled function checks in && expressions (#49868) 2022-07-22 16:06:16 -07:00
Oleksandr T
455ea9b41f fix(49964): handle auto-import dependencies/omit duplicate constraints (#50004) 2022-07-22 11:01:43 -07:00
Armando Aguirre
7b764164ed Fixed closing JSDoc when adding multiple blocks (#49888)
* Fixed closing JSDoc when adding multiple blocks

* Fixed linting errors

* Refactored to use `some`

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

* Removed empty lines

Co-authored-by: Armando Aguirre <araguir@microsoft.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-07-21 13:16:40 -07:00
Oleksandr T
5d2e62a810 fix(49854): fix start index to emit statements after super (#49858) 2022-07-20 16:02:30 -07:00
Oleksandr T
5702941c2f fix(49719): Incorrect error 2301 when using ES standard class properties (#49725)
* fix(49719): omit TS2301 error with enabled usedefineforclassfields

* show error for target lower than esnext with useddefineforclassfields enabled

* change target from esnext to es2022
2022-07-20 14:36:35 -07:00
Oleksandr T
f6ac10958f fix(49704): Code folding not working in file with simple syntax error (#49743)
* fix(49704): parse type arguments in super call expression

* omit duplicate errors
2022-07-19 16:26:56 -07:00
Nathan Shively-Sanders
7f3ca9f8f7 Copy type parameters to function with @type tag (#49960)
* Copy type parameters to function with @type tag

Previously, type references to generic types would fail to copy type
parameters from type references in an `@type` tag. Now the type
parameter is copied.

Note that I left 3 places in the checker unchanged, even though they
should technically also get type parameters from type refereneces:

1. getOuterTypeParameters -- not fixing this means that nested function
still won't get instantiated correctly. I'll see how hard this is to
fix.
2. getLocalTypeParameterOfClassOrInterfaceOrTypeAlias -- only applies to
constructor functions which have a type annotation, which doesn't type
check in the first place.
3. isThislessType -- This function is conservative, so should be
possible to make it more conservative without writing a lot of code.

Fixes #49039

* Update API baselines
2022-07-19 15:40:53 -07:00
Oleksandr T
5a53e9bb5e fix(49838): "Extract function" refactoring action is disabled for a wrong reason (#49840)
* fix(49838): allow extracting functions with a break statement inside loop context

* remove useless flag

* add more tests
2022-07-19 13:06:45 -07:00
Jake Bailey
05d20760af Don't leak EvolvingArray out of code flow (#49943) 2022-07-18 19:00:18 -07:00
Oleksandr T
3863cc4a20 feat(49786): show completions in expression with type arguments (#49810) 2022-07-18 14:55:15 -07:00
Oleksandr T
91f7cfc501 fix(49392): show optional class methods with enabled strict option (#49768) 2022-07-18 14:49:13 -07:00
Zzzen
efbe03a33c check base constraint when checking operand of plus (#49918) 2022-07-18 09:42:50 -07:00
Anders Hejlsberg
2c68ded954 Improve narrowing logic for instanceof, type predicate functions, and assertion functions (#49625)
* Improve narrowing logic for instanceof, type predicates, and assertions

* Accept new baselines

* Add tests

* Tweak algorithm

* Accept new baselines

* Optimize for discriminated unions
2022-07-15 14:01:55 -10:00
Jake Bailey
cf3af3febd Properly propagate ObjectFlags.NonInferrableType, clean up non-inferrable code paths (#49887) 2022-07-14 18:33:09 -07:00
Mateusz Burzyński
cd3bd5522b Fixed an issue with generic naked T not being allowed as async generator's return (#49023) 2022-07-14 15:51:03 -07:00
Mateusz Burzyński
2ef3901940 Fixed initializaiton-time inference for class properties assigned through element access (#49374) 2022-07-13 14:43:23 -07:00
Babak K. Shandiz
8e6e87fea6 🐛 Fix smart selection of propery signatures having JSDoc comments (#49804)
* 🐛 Avoid grouping JSDoc nodes of propery signatures with others in smart selection

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>

* ⚗️ Add test case for JSDoc smart selection (#39618)

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>

* ⚗️ Add test baseline for JSDoc smart selection (#39618)

Signed-off-by: Babak K. Shandiz <babak.k.shandiz@gmail.com>

* 🐛 Fix skipping SyntaxList first child's JSDoc in smart selection

Signed-off-by: GitHub <noreply@github.com>

* ⚗️ Add tests to ensure not skipping first SyntaxList child's JSDoc

Signed-off-by: GitHub <noreply@github.com>

* 🔨 Exclude JSDoc token from tokens pivoting property signature

Signed-off-by: GitHub <noreply@github.com>

* ⚗️ Update test case to also include modifier

Signed-off-by: GitHub <noreply@github.com>

* ⚗️ Update test case reference baseline

Signed-off-by: GitHub <noreply@github.com>
2022-07-12 09:04:21 -07:00
Anders Hejlsberg
c2897189cb Defer types like keyof (T & {}) (#49696)
* 'keyof undefined' and 'keyof null same as 'keyof never'

* Update tests

* Defer types like `keyof (T & {})`

* Restore test

* Update test

* Accept new baselines

* Add tests
2022-07-07 11:54:22 -10:00
Anders Hejlsberg
2eaf49f56e Handle pseudo-references in getFlowCacheKey (#49828)
* Handle pseudo-references in getFlowCacheKey

* Add tests

* Accept new baselines
2022-07-07 11:53:30 -10:00
Andrew Branch
9dde56c6fc Add path completions for package.json exports with wildcards (#49644)
* Support path completions for exports wildcards

* Break up results by directory

* Share code between typesVersions and exports processing

* Revert completion kind change

* Add kinds to tests

* Update existing test

* Support nested conditions, improve recursive globbing
2022-07-07 12:26:18 -07:00