Skip to content

Commit 57bd608

Browse files
TypeScript Botahejlsberg
TypeScript Bot
andauthored
Cherry-pick PR microsoft#47738 into release-4.6 (microsoft#47907)
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 <[email protected]>
1 parent ea5a43a commit 57bd608

33 files changed

+442
-711
lines changed

src/compiler/checker.ts

+284-301
Large diffs are not rendered by default.

src/compiler/diagnosticMessages.json

+8
Original file line numberDiff line numberDiff line change
@@ -871,6 +871,14 @@
871871
"category": "Error",
872872
"code": 1269
873873
},
874+
"Decorator function return type '{0}' is not assignable to type '{1}'.": {
875+
"category": "Error",
876+
"code": 1270
877+
},
878+
"Decorator function return type is '{0}' but is expected to be 'void' or 'any'.": {
879+
"category": "Error",
880+
"code": 1271
881+
},
874882

875883
"'with' statements are not allowed in an async function block.": {
876884
"category": "Error",

src/compiler/types.ts

+2
Original file line numberDiff line numberDiff line change
@@ -5175,6 +5175,8 @@ namespace ts {
51755175
ESSymbolLike = ESSymbol | UniqueESSymbol,
51765176
VoidLike = Void | Undefined,
51775177
/* @internal */
5178+
DefinitelyNonNullable = StringLike | NumberLike | BigIntLike | BooleanLike | EnumLike | ESSymbolLike | Object | NonPrimitive,
5179+
/* @internal */
51785180
DisjointDomains = NonPrimitive | StringLike | NumberLike | BigIntLike | BooleanLike | ESSymbolLike | VoidLike | Null,
51795181
UnionOrIntersection = Union | Intersection,
51805182
StructuredType = Object | Union | Intersection,

tests/baselines/reference/bigintWithLib.errors.txt

-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ tests/cases/compiler/bigintWithLib.ts(31,35): error TS2769: No overload matches
2020
Argument of type 'number[]' is not assignable to parameter of type 'Iterable<bigint>'.
2121
Overload 3 of 3, '(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array', gave the following error.
2222
Argument of type 'number[]' is not assignable to parameter of type 'ArrayBufferLike'.
23-
Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
2423
tests/cases/compiler/bigintWithLib.ts(36,13): error TS2540: Cannot assign to 'length' because it is a read-only property.
2524
tests/cases/compiler/bigintWithLib.ts(43,25): error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.
2625
tests/cases/compiler/bigintWithLib.ts(46,26): error TS2345: Argument of type 'number' is not assignable to parameter of type 'bigint'.
@@ -84,7 +83,6 @@ tests/cases/compiler/bigintWithLib.ts(46,26): error TS2345: Argument of type 'nu
8483
!!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'Iterable<bigint>'.
8584
!!! error TS2769: Overload 3 of 3, '(buffer: ArrayBufferLike, byteOffset?: number, length?: number): BigUint64Array', gave the following error.
8685
!!! error TS2769: Argument of type 'number[]' is not assignable to parameter of type 'ArrayBufferLike'.
87-
!!! error TS2769: Type 'number[]' is not assignable to type 'SharedArrayBuffer'.
8886
bigUintArray = new BigUint64Array(new ArrayBuffer(80));
8987
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8);
9088
bigUintArray = new BigUint64Array(new ArrayBuffer(80), 8, 3);

tests/baselines/reference/checkJsdocTypeTagOnObjectProperty2.errors.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string | undefined'.
1+
tests/cases/conformance/jsdoc/0.js(5,3): error TS2322: Type 'number' is not assignable to type 'string'.
22
tests/cases/conformance/jsdoc/0.js(8,7): error TS2322: Type 'string' is not assignable to type 'number'.
33
tests/cases/conformance/jsdoc/0.js(11,20): error TS2322: Type 'string' is not assignable to type 'number'.
44
tests/cases/conformance/jsdoc/0.js(13,15): error TS2322: Type 'string' is not assignable to type 'number'.
@@ -15,7 +15,7 @@ tests/cases/conformance/jsdoc/0.js(22,22): error TS2345: Argument of type 'strin
1515
/** @type {string|undefined} */
1616
bar: 42,
1717
~~~~~~~
18-
!!! error TS2322: Type 'number' is not assignable to type 'string | undefined'.
18+
!!! error TS2322: Type 'number' is not assignable to type 'string'.
1919
/** @type {function(number): number} */
2020
method1(n1) {
2121
return "42";

tests/baselines/reference/checkJsxChildrenProperty4.errors.txt

-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
tests/cases/conformance/jsx/file.tsx(24,28): error TS2551: Property 'NAme' does not exist on type 'IUser'. Did you mean 'Name'?
22
tests/cases/conformance/jsx/file.tsx(36,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
3-
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
43
tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
5-
Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
64

75

86
==== tests/cases/conformance/jsx/file.tsx (3 errors) ====
@@ -51,7 +49,6 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) =
5149
) }
5250
~~~~~~~~~~~~~
5351
!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
54-
!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
5552
!!! related TS6212 tests/cases/conformance/jsx/file.tsx:36:15: Did you mean to call this expression?
5653
{ user => (
5754
~~~~~~~~~
@@ -60,7 +57,6 @@ tests/cases/conformance/jsx/file.tsx(39,15): error TS2322: Type '(user: IUser) =
6057
) }
6158
~~~~~~~~~~~~~
6259
!!! error TS2322: Type '(user: IUser) => Element' is not assignable to type 'boolean | any[] | ReactChild'.
63-
!!! error TS2322: Type '(user: IUser) => Element' is missing the following properties from type 'ReactElement<any>': type, props
6460
!!! related TS6212 tests/cases/conformance/jsx/file.tsx:39:15: Did you mean to call this expression?
6561
</FetchUser>
6662
);

0 commit comments

Comments
 (0)