Commit Graph

16401 Commits

Author SHA1 Message Date
Anders Hejlsberg
697935da47 Restore ordering of operations involving type parameters and unions (#50116) 2022-08-03 00:32:41 -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
Sheetal Nandi
394f51aeed Fix implied formats, file watching, new source file creating during edits (#50098)
* Add test where module resolution cache is not local and hence doesnt report errors in watch mode

* Ensure module resolution cache is passed through in watch mode

* Remove unnecessary setting of impliedFormat which should anyways be done as part of create source file

* Add test for packge.json changing and modifying implied format

* Distinguish between package.json watch and affecting file location watch

* Pass in failed lookup and affected file locations for source file's implied format
Also stop creating options if we already have them

* Add diagnostic for explaining file's implied format if based on package.json

* Watch implied format dependencies for modules and schedule update on change

* For program if implied node format doesnt match create new source file. Handle implied node format in document registry
Fixes #50086

* Modify tests to show package.json being watched irrespective of folder its in

* Check file path if it can be watched before watching package.json file

* Because we are watching package.json files and failed lookups its safe to invalidate package json entries instead of clearing them out everytime program is created

* Remove todos

* Fix the incorrect merge

* Pickup PackageJsonInfo renames from #50088

* Rename
2022-08-01 12:41:37 -07: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
Zzzen
1490037f17 fix dts generation of jsdoc (#49904) 2022-07-28 17:44:23 -07:00
Sheetal Nandi
5d790526a1 Pass correct module resolution state when reading package.json info so that they are correctly tracked in the resolution (#50085) 2022-07-28 17:19:10 -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
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
Jake Bailey
df58836577 Use proper type for result of resultModuleNamesReusingOldState (#50012) 2022-07-27 09:30:52 -07:00
Anders Hejlsberg
a4507c9225 Favor asserted type in type predicate narrowing (#50044)
* Favor asserted type in type predicate narrowing

* Accept new baselines
2022-07-26 17:39:35 -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
Jake Bailey
b5b02eefc8 Walk tokens with the correct walker (#50042) 2022-07-25 14:26:00 -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
Jake Bailey
4e23f515e0 Protect watcher from double close (#49990) 2022-07-22 13:32:16 -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
Jake Bailey
aba867d15a Clean up inference of type parameters, contravariant types (#49915) 2022-07-19 15:30:48 -07:00
Jake Bailey
05d20760af Don't leak EvolvingArray out of code flow (#49943) 2022-07-18 19:00:18 -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
Nathan Shively-Sanders
a21024dbe7 Delete unused code in object literal binding (#49879)
It doesn't do anything anymore. I'm not sure what it used to do; it's
been there basically forever.
2022-07-14 13:22:14 -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
Andrew Branch
695b24d187 Move DebugTypeMapper to debug.ts (#49864)
* Move DebugTypeMapper to debug.ts

* export `DebugType`
2022-07-11 13:25:33 -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
AlCalzone
f6684be95e fix: correct name length criterion for spelling fixes (#49575)
Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com>
2022-07-07 09:08:37 -07:00
Jake Bailey
59238dbf90 Make contextFlags an explicitly required parameter (#49720) 2022-07-06 16:11:39 -07:00
Oleksandr T
8ae1e9e7c7 fix(49685): omit incorrect visibility error when setter precedes getter (#49697) 2022-07-06 15:59:05 -07:00
Jake Bailey
94a65769d4 Add debug format helpers for more enums (#49732) 2022-07-06 15:35:57 -07:00
Wesley Wigham
9872184483 Remove dependence on module compiler option to consider mts/cts files always modules (#49815) 2022-07-06 13:26:36 -07:00
Wesley Wigham
eb430f27ea More documentation on the impliedNodeFormat SourceFile field (#49816) 2022-07-06 13:25:58 -07:00
Jake Bailey
af70f240a1 Always resetErrorInfo if structuredTypeRelatedTo succeeds (#49718) 2022-07-06 12:57:01 -07:00
Mateusz Burzyński
8687940398 Add visible alias statements for non-visible binding patterns when emitting declaration (#48869) 2022-07-06 10:08:17 -07:00
Wesley Wigham
0f868035af Constrain infer type parameters made to preserver distributivity for inlined homomorphic mapped types (#49793) 2022-07-06 09:32:37 -07:00
Oleksandr T
e2e3c1285f fix(49544): allow comma token after accessors (#49545) 2022-07-06 08:54:54 -07:00
Jake Bailey
641ab8eb97 Infer rest type without using assignContextualParameterTypes (#49740) 2022-07-06 08:27:56 -07:00
Andrew Casey
2876f3ae85 Minor fixes (#49791)
* Fix operator precedence

* Tidy up some conditions with statically knowable values
2022-07-05 15:02:14 -07:00
Oleksandr T
cdc1996e87 fix(49426): Object method snippet completions incorrectly add this parameters (#49757)
* fix(49426): omit this parameter

* add OmitThisParameter to TypeFormatFlags

* change flag value
2022-07-05 11:46:19 -07:00