Skip to content

Commit 71c1da0

Browse files
authored
redo #28564 (#36665)
1 parent 1e48cbe commit 71c1da0

File tree

274 files changed

+1691
-1374
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

274 files changed

+1691
-1374
lines changed

Diff for: src/compiler/checker.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -24886,7 +24886,7 @@ namespace ts {
2488624886
}
2488724887
}
2488824888

24889-
return produceDiagnostics || !args ? resolveErrorCall(node) : getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
24889+
return getCandidateForOverloadFailure(node, candidates, args, !!candidatesOutArray);
2489024890

2489124891
function chooseOverload(candidates: Signature[], relation: Map<RelationComparisonResult>, signatureHelpTrailingComma = false) {
2489224892
candidatesForArgumentError = undefined;

Diff for: tests/baselines/reference/argumentExpressionContextualTyping.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ baz(array); // Error
122122
baz(["string", 1, true, ...array]); // Error
123123
>baz(["string", 1, true, ...array]) : void
124124
>baz : (x: [string, number, boolean]) => void
125-
>["string", 1, true, ...array] : (string | number | boolean)[]
125+
>["string", 1, true, ...array] : [string, number, true, ...(string | number | boolean)[]]
126126
>"string" : "string"
127127
>1 : 1
128128
>true : true

Diff for: tests/baselines/reference/arrayAssignmentTest3.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class a {
1717

1818

1919
var xx = new a(null, 7, new B());
20-
>xx : any
21-
>new a(null, 7, new B()) : any
20+
>xx : a
21+
>new a(null, 7, new B()) : a
2222
>a : typeof a
2323
>null : null
2424
>7 : 7

Diff for: tests/baselines/reference/baseCheck.errors.txt

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
tests/cases/compiler/baseCheck.ts(9,18): error TS2552: Cannot find name 'loc'. Did you mean 'ELoc'?
22
tests/cases/compiler/baseCheck.ts(17,53): error TS2554: Expected 2 arguments, but got 1.
3-
tests/cases/compiler/baseCheck.ts(17,59): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
43
tests/cases/compiler/baseCheck.ts(18,62): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
54
tests/cases/compiler/baseCheck.ts(19,59): error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
6-
tests/cases/compiler/baseCheck.ts(19,68): error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
75
tests/cases/compiler/baseCheck.ts(22,9): error TS2304: Cannot find name 'x'.
86
tests/cases/compiler/baseCheck.ts(23,7): error TS2304: Cannot find name 'x'.
97
tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
108

119

12-
==== tests/cases/compiler/baseCheck.ts (9 errors) ====
10+
==== tests/cases/compiler/baseCheck.ts (7 errors) ====
1311
class C { constructor(x: number, y: number) { } }
1412
class ELoc extends C {
1513
constructor(x: number) {
@@ -33,16 +31,12 @@ tests/cases/compiler/baseCheck.ts(26,9): error TS2304: Cannot find name 'x'.
3331
~~~~~~~~~~~~~
3432
!!! error TS2554: Expected 2 arguments, but got 1.
3533
!!! related TS6210 tests/cases/compiler/baseCheck.ts:1:34: An argument for 'y' was not provided.
36-
~~~~
37-
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
3834
class E extends C { constructor(public z: number) { super(0, this.z) } }
3935
~~~~
4036
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
4137
class F extends C { constructor(public z: number) { super("hello", this.z) } } // first param type
4238
~~~~~~~
4339
!!! error TS2345: Argument of type '"hello"' is not assignable to parameter of type 'number'.
44-
~~~~
45-
!!! error TS17009: 'super' must be called before accessing 'this' in the constructor of a derived class.
4640

4741
function f() {
4842
if (x<10) {

Diff for: tests/baselines/reference/bigintWithLib.types

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ bigIntArray = new BigInt64Array([1n, 2n, 3n]);
9494
>3n : 3n
9595

9696
bigIntArray = new BigInt64Array([1, 2, 3]); // should error
97-
>bigIntArray = new BigInt64Array([1, 2, 3]) : any
97+
>bigIntArray = new BigInt64Array([1, 2, 3]) : BigInt64Array
9898
>bigIntArray : BigInt64Array
99-
>new BigInt64Array([1, 2, 3]) : any
99+
>new BigInt64Array([1, 2, 3]) : BigInt64Array
100100
>BigInt64Array : BigInt64ArrayConstructor
101101
>[1, 2, 3] : number[]
102102
>1 : 1
@@ -174,9 +174,9 @@ bigUintArray = new BigUint64Array([1n, 2n, 3n]);
174174
>3n : 3n
175175

176176
bigUintArray = new BigUint64Array([1, 2, 3]); // should error
177-
>bigUintArray = new BigUint64Array([1, 2, 3]) : any
177+
>bigUintArray = new BigUint64Array([1, 2, 3]) : BigUint64Array
178178
>bigUintArray : BigUint64Array
179-
>new BigUint64Array([1, 2, 3]) : any
179+
>new BigUint64Array([1, 2, 3]) : BigUint64Array
180180
>BigUint64Array : BigUint64ArrayConstructor
181181
>[1, 2, 3] : number[]
182182
>1 : 1

Diff for: tests/baselines/reference/bigintWithoutLib.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ let stringVal: string = bigintVal.toString(); // should not error - bigintVal in
5656
>toString : () => string
5757

5858
stringVal = bigintVal.toString(2); // should error - bigintVal inferred as {}
59-
>stringVal = bigintVal.toString(2) : any
59+
>stringVal = bigintVal.toString(2) : string
6060
>stringVal : string
6161
>bigintVal.toString(2) : string
6262
>bigintVal.toString : () => string

Diff for: tests/baselines/reference/blockScopedSameNameFunctionDeclarationES5.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function foo(a: number) {
1616
>foo : { (): void; (): void; }
1717

1818
foo(10); // not ok
19-
>foo(10) : any
19+
>foo(10) : void
2020
>foo : { (): void; (): void; }
2121
>10 : 10
2222
}
@@ -29,12 +29,12 @@ function foo(a: number) {
2929
>foo : { (): void; (): void; }
3030

3131
foo(10); // not ok
32-
>foo(10) : any
32+
>foo(10) : void
3333
>foo : { (): void; (): void; }
3434
>10 : 10
3535
}
3636
foo(10); // not ok
37-
>foo(10) : any
37+
>foo(10) : void
3838
>foo : { (): void; (): void; }
3939
>10 : 10
4040

Diff for: tests/baselines/reference/blockScopedSameNameFunctionDeclarationES6.types

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function foo(a: number) {
1616
>foo : { (): void; (): void; }
1717

1818
foo(10); // not ok
19-
>foo(10) : any
19+
>foo(10) : void
2020
>foo : { (): void; (): void; }
2121
>10 : 10
2222
}
@@ -29,12 +29,12 @@ function foo(a: number) {
2929
>foo : { (): void; (): void; }
3030

3131
foo(10);// not ok
32-
>foo(10) : any
32+
>foo(10) : void
3333
>foo : { (): void; (): void; }
3434
>10 : 10
3535
}
3636
foo(10); // not ok
37-
>foo(10) : any
37+
>foo(10) : void
3838
>foo : { (): void; (): void; }
3939
>10 : 10
4040

Diff for: tests/baselines/reference/callGenericFunctionWithIncorrectNumberOfTypeArguments.types

+20-20
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,15 @@ function f<T, U>(x: T, y: U): T { return null; }
99
>null : null
1010

1111
var r1 = f<number>(1, '');
12-
>r1 : any
13-
>f<number>(1, '') : any
12+
>r1 : number
13+
>f<number>(1, '') : number
1414
>f : <T, U>(x: T, y: U) => T
1515
>1 : 1
1616
>'' : ""
1717

1818
var r1b = f<number, string, number>(1, '');
19-
>r1b : any
20-
>f<number, string, number>(1, '') : any
19+
>r1b : number
20+
>f<number, string, number>(1, '') : number
2121
>f : <T, U>(x: T, y: U) => T
2222
>1 : 1
2323
>'' : ""
@@ -30,15 +30,15 @@ var f2 = <T, U>(x: T, y: U): T => { return null; }
3030
>null : null
3131

3232
var r2 = f2<number>(1, '');
33-
>r2 : any
34-
>f2<number>(1, '') : any
33+
>r2 : number
34+
>f2<number>(1, '') : number
3535
>f2 : <T, U>(x: T, y: U) => T
3636
>1 : 1
3737
>'' : ""
3838

3939
var r2b = f2<number, string, number>(1, '');
40-
>r2b : any
41-
>f2<number, string, number>(1, '') : any
40+
>r2b : number
41+
>f2<number, string, number>(1, '') : number
4242
>f2 : <T, U>(x: T, y: U) => T
4343
>1 : 1
4444
>'' : ""
@@ -49,15 +49,15 @@ var f3: { <T, U>(x: T, y: U): T; }
4949
>y : U
5050

5151
var r3 = f3<number>(1, '');
52-
>r3 : any
53-
>f3<number>(1, '') : any
52+
>r3 : number
53+
>f3<number>(1, '') : number
5454
>f3 : <T, U>(x: T, y: U) => T
5555
>1 : 1
5656
>'' : ""
5757

5858
var r3b = f3<number, string, number>(1, '');
59-
>r3b : any
60-
>f3<number, string, number>(1, '') : any
59+
>r3b : number
60+
>f3<number, string, number>(1, '') : number
6161
>f3 : <T, U>(x: T, y: U) => T
6262
>1 : 1
6363
>'' : ""
@@ -75,8 +75,8 @@ class C {
7575
}
7676
}
7777
var r4 = (new C()).f<number>(1, '');
78-
>r4 : any
79-
>(new C()).f<number>(1, '') : any
78+
>r4 : number
79+
>(new C()).f<number>(1, '') : number
8080
>(new C()).f : <T, U>(x: T, y: U) => T
8181
>(new C()) : C
8282
>new C() : C
@@ -86,8 +86,8 @@ var r4 = (new C()).f<number>(1, '');
8686
>'' : ""
8787

8888
var r4b = (new C()).f<number, string, number>(1, '');
89-
>r4b : any
90-
>(new C()).f<number, string, number>(1, '') : any
89+
>r4b : number
90+
>(new C()).f<number, string, number>(1, '') : number
9191
>(new C()).f : <T, U>(x: T, y: U) => T
9292
>(new C()) : C
9393
>new C() : C
@@ -106,17 +106,17 @@ var i: I;
106106
>i : I
107107

108108
var r5 = i.f<number>(1, '');
109-
>r5 : any
110-
>i.f<number>(1, '') : any
109+
>r5 : number
110+
>i.f<number>(1, '') : number
111111
>i.f : <T, U>(x: T, y: U) => T
112112
>i : I
113113
>f : <T, U>(x: T, y: U) => T
114114
>1 : 1
115115
>'' : ""
116116

117117
var r5b = i.f<number, string, number>(1, '');
118-
>r5b : any
119-
>i.f<number, string, number>(1, '') : any
118+
>r5b : number
119+
>i.f<number, string, number>(1, '') : number
120120
>i.f : <T, U>(x: T, y: U) => T
121121
>i : I
122122
>f : <T, U>(x: T, y: U) => T

Diff for: tests/baselines/reference/callSignaturesShouldBeResolvedBeforeSpecialization.types

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ function foo() {
1919
>"expects boolean instead of string" : "expects boolean instead of string"
2020

2121
test(true); // should error - string expected
22-
>test(true) : any
22+
>test(true) : void
2323
>test : I1<string>
2424
>true : true
2525
}

Diff for: tests/baselines/reference/callWithMissingVoid.types

+4-4
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,23 @@ new MyPromise<void | number>(resolve => resolve()); // no error
9999
new MyPromise<any>(resolve => resolve()); // error, `any` arguments cannot be omitted
100100
>new MyPromise<any>(resolve => resolve()) : MyPromise<any>
101101
>MyPromise : typeof MyPromise
102-
>resolve => resolve() : (resolve: (value: any) => void) => any
102+
>resolve => resolve() : (resolve: (value: any) => void) => void
103103
>resolve : (value: any) => void
104104
>resolve() : void
105105
>resolve : (value: any) => void
106106

107107
new MyPromise<unknown>(resolve => resolve()); // error, `unknown` arguments cannot be omitted
108108
>new MyPromise<unknown>(resolve => resolve()) : MyPromise<unknown>
109109
>MyPromise : typeof MyPromise
110-
>resolve => resolve() : (resolve: (value: unknown) => void) => any
110+
>resolve => resolve() : (resolve: (value: unknown) => void) => void
111111
>resolve : (value: unknown) => void
112112
>resolve() : void
113113
>resolve : (value: unknown) => void
114114

115115
new MyPromise<never>(resolve => resolve()); // error, `never` arguments cannot be omitted
116116
>new MyPromise<never>(resolve => resolve()) : MyPromise<never>
117117
>MyPromise : typeof MyPromise
118-
>resolve => resolve() : (resolve: (value: never) => void) => any
118+
>resolve => resolve() : (resolve: (value: never) => void) => void
119119
>resolve : (value: never) => void
120120
>resolve() : void
121121
>resolve : (value: never) => void
@@ -234,7 +234,7 @@ declare function call<TS extends unknown[]>(
234234
>args : TS
235235

236236
call((x: number, y: number) => x + y) // error
237-
>call((x: number, y: number) => x + y) : any
237+
>call((x: number, y: number) => x + y) : void
238238
>call : <TS extends unknown[]>(handler: (...args: TS) => unknown, ...args: TS) => void
239239
>(x: number, y: number) => x + y : (x: number, y: number) => number
240240
>x : number

Diff for: tests/baselines/reference/callWithWrongNumberOfTypeArguments.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ function f<T, U>() { }
33
>f : <T, U>() => void
44

55
f<number>();
6-
>f<number>() : any
6+
>f<number>() : void
77
>f : <T, U>() => void
88

99
f<number, string>();
1010
>f<number, string>() : void
1111
>f : <T, U>() => void
1212

1313
f<number, string, number>();
14-
>f<number, string, number>() : any
14+
>f<number, string, number>() : void
1515
>f : <T, U>() => void
1616

Diff for: tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.errors.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,64): error TS2741: Property 'z' is missing in type 'B' but required in type 'C'.
2+
tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts(19,81): error TS2739: Type 'A' is missing the following properties from type 'C': z, y
23

34

4-
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (1 errors) ====
5+
==== tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts (2 errors) ====
56
class Chain<T extends A> {
67
constructor(public value: T) { }
78
then<S extends T>(cb: (x: T) => S): Chain<S> {
@@ -24,4 +25,7 @@ tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParamete
2425
~~~~~
2526
!!! error TS2741: Property 'z' is missing in type 'B' but required in type 'C'.
2627
!!! related TS2728 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:15:5: 'z' is declared here.
28+
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature.
29+
~~~~~
30+
!!! error TS2739: Type 'A' is missing the following properties from type 'C': z, y
2731
!!! related TS6502 tests/cases/compiler/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts:3:27: The expected type comes from the return type of this signature.

Diff for: tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.symbols

+2
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class C extends B {
4646

4747
// Ok to go down the chain, but error to try to climb back up
4848
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
49+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
4950
>(new Chain(new A)).then(a => new B).then(b => new C).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
5051
>(new Chain(new A)).then(a => new B).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
5152
>(new Chain(new A)).then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
@@ -60,6 +61,7 @@ class C extends B {
6061
>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
6162
>c : Symbol(c, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 58))
6263
>B : Symbol(B, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 9, 1))
64+
>then : Symbol(Chain.then, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 1, 36))
6365
>b : Symbol(b, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 18, 75))
6466
>A : Symbol(A, Decl(chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.ts, 5, 1))
6567

Diff for: tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter.types

+6-6
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ class C extends B {
3838

3939
// Ok to go down the chain, but error to try to climb back up
4040
(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A);
41-
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A) : any
42-
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : any
43-
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B) : any
41+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then(b => new A) : Chain<C>
42+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B).then : <S extends C>(cb: (x: C) => S) => Chain<S>
43+
>(new Chain(new A)).then(a => new B).then(b => new C).then(c => new B) : Chain<C>
4444
>(new Chain(new A)).then(a => new B).then(b => new C).then : <S extends C>(cb: (x: C) => S) => Chain<S>
4545
>(new Chain(new A)).then(a => new B).then(b => new C) : Chain<C>
4646
>(new Chain(new A)).then(a => new B).then : <S extends B>(cb: (x: B) => S) => Chain<S>
@@ -66,9 +66,9 @@ class C extends B {
6666
>c : C
6767
>new B : B
6868
>B : typeof B
69-
>then : any
70-
>b => new A : (b: any) => A
71-
>b : any
69+
>then : <S extends C>(cb: (x: C) => S) => Chain<S>
70+
>b => new A : (b: C) => A
71+
>b : C
7272
>new A : A
7373
>A : typeof A
7474

Diff for: tests/baselines/reference/chainedCallsWithTypeParameterConstrainedToOtherTypeParameter2.types

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class Chain<T> {
1818

1919
// Ok to go down the chain, but error to climb up the chain
2020
(new Chain(t)).then(tt => s).then(ss => t);
21-
>(new Chain(t)).then(tt => s).then(ss => t) : any
21+
>(new Chain(t)).then(tt => s).then(ss => t) : Chain<S>
2222
>(new Chain(t)).then(tt => s).then : <S extends S>(cb: (x: S) => S) => Chain<S>
2323
>(new Chain(t)).then(tt => s) : Chain<S>
2424
>(new Chain(t)).then : <S extends T>(cb: (x: T) => S) => Chain<S>
@@ -37,7 +37,7 @@ class Chain<T> {
3737

3838
// But error to try to climb up the chain
3939
(new Chain(s)).then(ss => t);
40-
>(new Chain(s)).then(ss => t) : any
40+
>(new Chain(s)).then(ss => t) : Chain<S>
4141
>(new Chain(s)).then : <S extends S>(cb: (x: S) => S) => Chain<S>
4242
>(new Chain(s)) : Chain<S>
4343
>new Chain(s) : Chain<S>

0 commit comments

Comments
 (0)