Skip to content

Commit

Permalink
Cherry-pick PR #47738 into release-4.6 (#47907)
Browse files Browse the repository at this point in the history
Component commits:
628da10 Eliminate redundant or meaningless elaborations in type relations

a009ee1 Accept new baselines

a65794c Add resetErrorInfo (though, oddly, shouldn't be necessary)

f269f42 Less aggressive reduction in second pass union/intersection checks

1312e8a Accept new baselines

b82966f Restructure and back off a little bit more

f0b8742 Only cache union/intersection relations once

9404e06 Accept new baselines

4866ce5 Properly cache identity relations, clean up error reporting

2670b26 Move more logic to cached side of relation checks

adb37a5 Optimize and remove more redundant elaborations

16b986b Accept new baselines

1c69acb Remove unnecessary error state capture

530c876 More optimizing

25a71c4 Cache isWeakType computation

c427a46 Revert "Cache isWeakType computation"
This reverts commit 25a71c4.

1d70b01 Address CR feedback

28439f7 Merge branch 'main' into fix47668
# Conflicts:
#	src/compiler/diagnosticMessages.json

c472ba5 Accept new baselines

Co-authored-by: Anders Hejlsberg <andersh@microsoft.com>
  • Loading branch information
TypeScript Bot and ahejlsberg authored Feb 18, 2022
1 parent ea5a43a commit 57bd608
Show file tree
Hide file tree
Showing 33 changed files with 442 additions and 711 deletions.
585 changes: 284 additions & 301 deletions src/compiler/checker.ts

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions src/compiler/diagnosticMessages.json
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,14 @@
"category": "Error",
"code": 1269
},
"Decorator function return type '{0}' is not assignable to type '{1}'.": {
"category": "Error",
"code": 1270
},
"Decorator function return type is '{0}' but is expected to be 'void' or 'any'.": {
"category": "Error",
"code": 1271
},

"'with' statements are not allowed in an async function block.": {
"category": "Error",
Expand Down
2 changes: 2 additions & 0 deletions src/compiler/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5175,6 +5175,8 @@ namespace ts {
ESSymbolLike = ESSymbol | UniqueESSymbol,
VoidLike = Void | Undefined,
/* @internal */
DefinitelyNonNullable = StringLike | NumberLike | BigIntLike | BooleanLike | EnumLike | ESSymbolLike | Object | NonPrimitive,
/* @internal */
DisjointDomains = NonPrimitive | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbolLike | VoidLike | Null,
UnionOrIntersection = Union | Intersection,
StructuredType = Object | Union | Intersection,
Expand Down
2 changes: 0 additions & 2 deletions tests/baselines/reference/bigintWithLib.errors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ tests/cases/compiler/bigintWithLib.ts(31,35): error TS2769: No overload matches
Argument of type 'number[]' is not assignable to parameter of type 'Iterable<bigint>'.
Overload 3 of 3, '(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array', gave the following error.
Argument of type 'number[]' is not assignable to parameter of type 'ArrayBufferLike'.
Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
tests/cases/compiler/bigintWithLib.ts(36,13): error TS2540: Cannot assign to 'length' because it is a read-only property.
tests/cases/compiler/bigintWithLib.ts(43,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.
tests/cases/compiler/bigintWithLib.ts(46,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.
Expand Down Expand Up @@ -84,7 +83,6 @@ tests/cases/compiler/bigintWithLib.ts(46,26): error TS2345: Argument of type 'nu
!!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'Iterable<bigint>'.
!!! error TS2769: Overload 3 of 3, '(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array', gave the following error.
!!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBufferLike'.
!!! error TS2769: Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string | undefined'.
tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'.
tests/cases/conformance/jsdoc/0.js(8,7): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/jsdoc/0.js(11,20): error TS2322: Type 'string' is not assignable to type 'number'.
tests/cases/conformance/jsdoc/0.js(13,15): error TS2322: Type 'string' is not assignable to type 'number'.
Expand All @@ -15,7 +15,7 @@ tests/cases/conformance/jsdoc/0.js(22,22): error TS2345: Argument of type 'strin
/** @type {string|undefined} */
bar: 42,
~~~~~~~
!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'.
!!! error TS2322: Type 'number' is not assignable to type 'string'.
/** @type {function(number): number} */
method1(n1) {
return "42";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'?
tests/cases/conformance/jsx/file.tsx(36,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props


==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
Expand Down Expand Up @@ -51,7 +49,6 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) =
) }
~~~~~~~~~~~~~
!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
!!! related TS6212 tests/cases/conformance/jsx/file.tsx:36:15: Did you mean to call this expression?
{ user => (
~~~~~~~~~
Expand All @@ -60,7 +57,6 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) =
) }
~~~~~~~~~~~~~
!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
!!! related TS6212 tests/cases/conformance/jsx/file.tsx:39:15: Did you mean to call this expression?
</FetchUser>
);
Expand Down
Loading

0 comments on commit 57bd608

Please sign in to comment.