3973 Commits

Author SHA1 Message Date
Anders Hejlsberg
60963d7216
Discriminant of type never should never be matched (#50755)
* Discriminant of type 'never' should never be matched

* Add tests
2022-09-13 10:29:50 -07:00
Jake Bailey
f5f2923c7d
Revert removal of nonInferrableAnyType (#50691) 2022-09-12 15:10:29 -07:00
Anders Hejlsberg
a70bb9d3ff
Preserve special intersections in mapped types (#50704)
* Preserve special intersections in mapped types

* Add regression test
2022-09-09 12:09:50 -07:00
Andrew Branch
bb6f36f7c8
Forward intersection state flag to conditional type target check (#50620) 2022-09-07 10:07:24 -07:00
Will Nayes
fd3a84c3f0
Report every instance of TS1208 (#50101)
* Report every instance of TS1208

* Test case for multiple cases of TS1208

* Add test case for isolatedModules with moduleDetection forced
2022-09-02 13:44:47 -07:00
Andrew Branch
856c7c5fdd
Allow {} to narrow in same special cases as unknown (#50601) 2022-09-02 09:47:27 -07:00
Anders Hejlsberg
854d448e5c
in operator shouldn't narrow {} originating in unknown (#50610)
* 'in' operator shouldn't narrow {} originating in unknown

* Add regression test
2022-09-02 09:30:17 -07:00
Andrew Branch
5df09a514c
Use bidirectional comparability in narrowing (#50592)
* Use bidirectional comparability (aka comparability) in narrowing

* Rename test, check other CFA branch, test without strictNullChecks
2022-09-01 14:26:48 -07:00
Anders Hejlsberg
6db2c882f3
{} & null and {} & undefined should always be never (#50553)
* {} & null and {} & undefined should be never in non-strictNullChecks mode

* Add tests

* Address code review feedback

* Accept new baselines
2022-09-01 12:37:13 -07:00
Mateusz Burzyński
238c341701
Defer distributing index over generic object types (#50540)
* Defer distributing index over generic object types

* Only check if the index type should be deferred for intersection types

* Add an additional test case
2022-09-01 07:28:13 -07:00
Oleksandr T
a9797d218d
fix(50340): typeof ... === "undefined" check on discriminated union of undefined and object type doesn't narrow correctly (#50344)
* fix(50340): narrow type by discriminant in typeof

* add additional test cases
2022-08-31 15:00:50 -07:00
Wesley Wigham
488d0eebd0
Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword (#50537)
* Retain name and propertyName in declaration emit copies of binding patterns if property name is a keyword

* Accept baselines

* Remove out of date file
2022-08-30 09:03:02 -07:00
Joost Koehoorn
71b2ba6111
Reuse computed type of condition expressions (#49881) 2022-08-27 01:40:13 -07:00
Oleksandr T
5969ae9ef7
fix(50075): do not strip undefined from the function class properties (#50169) 2022-08-19 09:34:42 -07:00
Wesley Wigham
05d7d6bb12
Unify default import resolution across specifier target codepaths (#49814)
* Unify default import resolution across specifier target codepaths

* Use differing type aliases, per request
2022-08-19 02:25:41 -07:00
DetachHead
3b80ddca21
fix first match in RegExpMatchArray being possibly undefined when noUncheckedIndexedAccess is enabled (#49682)
* fix first match in `RegExpMatchArray` being possibly undefined when `noUncheckedIndexedAccess` is enabled

* fix tests

* add test

Co-authored-by: DetachHead <detachhead@users.noreply.github.com>
Co-authored-by: Nathan Shively-Sanders <293473+sandersn@users.noreply.github.com>
2022-08-16 10:12:12 -07:00
Andrew Branch
4e33e0eb6c
Make literal types not comparable to weak object types without property overlap (#49865) 2022-08-15 17:10:11 -07:00
Andrew Branch
64ee1e88e0
Strip literal freshness of contextually typed literals (#49884)
* Strip literal freshness of contextually typed literals

* Add more tests
2022-08-15 17:04:09 -07:00
Wesley Wigham
e989d840f1
Forward intersectionState flag when comparing indexed access constraints (#50261) 2022-08-15 16:10:32 -07:00
Ryan Cavanaugh
adf26ffa4b
Revert "Fixed an issue with contextual type for intersection properties (#48668)" (#50279)
This reverts commit 9236e39374c0ec9a1e3f9894af4fb9eb34ba0021.
2022-08-12 10:24:50 -07:00
Jake Bailey
5fbf3b04dc
Don't treat object properties as potential JS contructors without JSDoc class tag (#49735) 2022-08-10 11:19:19 -07:00
Jack Works
382f0c3af3
fix: crashes when JSX.IntrinsicClassAttributes is an alias type close GH-50254 (#50257) 2022-08-10 10:41:12 -07:00
Nathan Shively-Sanders
dd98c17b10
Merge multiple symbols even when re-exported (#49987)
* Merge multiple symbols even when re-exported

As far as I remember, the target of `mergeSymbol` needs to be a merged
symbol, not a symbol with a mergeId that points to mergedSymbol.
However, mergeSymbolTable didn't check for this.

I can't remember if symbol tables may contain
symbols-with-mergeId. If they can, then mergeSymbolTable needs to call
getMergedSymbol on the individual targets of the merge. That's what I
did in this PR.

* Call getMergeSymbol eagerly

On the source, not target, of mergeSymbolTable's contents
2022-08-09 16:36:53 -07:00
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
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 be387e3bbf8a5cce2bc4c31fd77b061ea6cf8e0b.

* 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
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
Ron Buckton
55f2c0cb49
No synthetic Awaited for unconstrained type when not a type variable (#50100) 2022-08-01 17:19:15 -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
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
3afe2d654e
Resolve parsingContextErrors TODO (#50011)
* Add a test with broken code

* Resolve TODO
2022-07-26 08:59:06 -07: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
Andrew Branch
6aefc1dcea
More fixes to uncalled function checks in && expressions (#49868) 2022-07-22 16:06: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
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
2ef3901940
Fixed initializaiton-time inference for class properties assigned through element access (#49374) 2022-07-13 14:43:23 -07:00
Oleksandr T
8ae1e9e7c7
fix(49685): omit incorrect visibility error when setter precedes getter (#49697) 2022-07-06 15:59:05 -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
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
Jake Bailey
641ab8eb97
Infer rest type without using assignContextualParameterTypes (#49740) 2022-07-06 08:27:56 -07:00
iamharbie
1f0d0f7c66
Set Error.prototype.cause type to unknown (#70) (#49639)
Signed-off-by: Abdul-Azeez Lawal <abdul-azeez.lawal@outlook.com>
2022-07-05 15:43:43 -07:00
Ron Buckton
c6ff5f3b52
Fix for Awaited<T> inference (#49748) 2022-07-01 15:00:54 -07:00
Andrew Branch
f8aa570b23
Get type arguments lazily for instantiating inferred type parameter constraint (#49744)
* Get type arguments lazily for instantiating inferred constraint

* Use new deferred type mapper
2022-06-30 16:23:07 -07:00