Skip to content

Commit a4f9bf0

Browse files
authored
Create type aliases for unresolved type symbols (#45976)
* Create type aliases for unresolved type symbols * Accept new baselines * Update fourslash tests * Unresolved import aliases create tagged unresolved symbols * Add comments * Accept new baselines * Add fourslash tests
1 parent 0396723 commit a4f9bf0

File tree

443 files changed

+10964
-6380
lines changed

Some content is hidden

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

443 files changed

+10964
-6380
lines changed

src/compiler/checker.ts

Lines changed: 121 additions & 59 deletions
Large diffs are not rendered by default.

src/compiler/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4957,6 +4957,7 @@ namespace ts {
49574957
HasNeverType = 1 << 17, // Synthetic property with at least one never type in constituents
49584958
Mapped = 1 << 18, // Property of mapped type
49594959
StripOptional = 1 << 19, // Strip optionality in mapped property
4960+
Unresolved = 1 << 20, // Unresolved type alias symbol
49604961
Synthetic = SyntheticProperty | SyntheticMethod,
49614962
Discriminant = HasNonUniformType | HasLiteralType,
49624963
Partial = ReadPartial | WritePartial

tests/baselines/reference/ArrowFunction1.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
var v = (a: ) => {
33
>v : Symbol(v, Decl(ArrowFunction1.ts, 0, 3))
44
>a : Symbol(a, Decl(ArrowFunction1.ts, 0, 9))
5+
> : Symbol(unknown)
56

67
};

tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.symbols

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ module clodule1 {
1919
function f(x: T) { }
2020
>f : Symbol(f, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 8, 17))
2121
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 9, 15))
22+
>T : Symbol(T)
2223
}
2324

2425
class clodule2<T>{
@@ -38,10 +39,12 @@ module clodule2 {
3839

3940
var x: T;
4041
>x : Symbol(x, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 19, 7))
42+
>T : Symbol(T)
4143

4244
class D<U extends T>{
4345
>D : Symbol(D, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 19, 13))
4446
>U : Symbol(U, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 21, 12))
47+
>T : Symbol(T)
4548

4649
id: string;
4750
>id : Symbol(D.id, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 21, 25))
@@ -92,6 +95,7 @@ module clodule4 {
9295

9396
name: T;
9497
>name : Symbol(D.name, Decl(ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.ts, 44, 13))
98+
>T : Symbol(T)
9599
}
96100
}
97101

tests/baselines/reference/ClassAndModuleThatMergeWithModuleMemberThatUsesClassTypeParameter.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ module clodule1 {
1515
>clodule1 : typeof clodule1
1616

1717
function f(x: T) { }
18-
>f : (x: any) => void
19-
>x : any
18+
>f : (x: T) => void
19+
>x : T
2020
}
2121

2222
class clodule2<T>{
@@ -33,7 +33,7 @@ module clodule2 {
3333
>clodule2 : typeof clodule2
3434

3535
var x: T;
36-
>x : any
36+
>x : T
3737

3838
class D<U extends T>{
3939
>D : D<U>
@@ -83,7 +83,7 @@ module clodule4 {
8383
>D : D
8484

8585
name: T;
86-
>name : any
86+
>name : T
8787
}
8888
}
8989

tests/baselines/reference/FunctionDeclaration13_es6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ function * foo() {
55
// Legal to use 'yield' in a type context.
66
var v: yield;
77
>v : Symbol(v, Decl(FunctionDeclaration13_es6.ts, 2, 6))
8+
>yield : Symbol(yield)
89
}
910

tests/baselines/reference/FunctionDeclaration13_es6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ function * foo() {
44

55
// Legal to use 'yield' in a type context.
66
var v: yield;
7-
>v : any
7+
>v : yield
88
}
99

tests/baselines/reference/ParameterList5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
function A(): (public B) => C {
33
>A : Symbol(A, Decl(ParameterList5.ts, 0, 0))
44
>B : Symbol(B, Decl(ParameterList5.ts, 0, 15))
5+
>C : Symbol(C)
56
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
=== tests/cases/compiler/ParameterList5.ts ===
22
function A(): (public B) => C {
3-
>A : () => (B: any) => any
3+
>A : () => (B: any) => C
44
>B : any
55
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
=== tests/cases/conformance/parser/ecmascript5/TupleTypes/TupleType6.ts ===
22
var v: [number,,]
33
>v : Symbol(v, Decl(TupleType6.ts, 0, 3))
4+
> : Symbol(unknown)
45

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.symbols

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export module A {
4848
// collision with 'Origin' var in other part of merged module
4949
export var Origin: Point = { x: 0, y: 0 };
5050
>Origin : Symbol(Origin, Decl(part2.ts, 2, 14))
51+
>Point : Symbol(Point)
5152
>x : Symbol(x, Decl(part2.ts, 2, 32))
5253
>y : Symbol(y, Decl(part2.ts, 2, 38))
5354

@@ -59,7 +60,9 @@ export module A {
5960

6061
constructor(public tl: Point, public br: Point) { }
6162
>tl : Symbol(Plane.tl, Decl(part2.ts, 6, 24))
63+
>Point : Symbol(Point)
6264
>br : Symbol(Plane.br, Decl(part2.ts, 6, 41))
65+
>Point : Symbol(Point)
6366
}
6467
}
6568
}

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedLocalVarsOfTheSameName.types

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export module A {
4545

4646
// collision with 'Origin' var in other part of merged module
4747
export var Origin: Point = { x: 0, y: 0 };
48-
>Origin : any
48+
>Origin : Point
4949
>{ x: 0, y: 0 } : { x: number; y: number; }
5050
>x : number
5151
>0 : 0
@@ -59,8 +59,8 @@ export module A {
5959
>Plane : Plane
6060

6161
constructor(public tl: Point, public br: Point) { }
62-
>tl : any
63-
>br : any
62+
>tl : Point
63+
>br : Point
6464
}
6565
}
6666
}

tests/baselines/reference/accessorDeclarationEmitVisibilityErrors.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export class Q {
55
set bet(arg: DoesNotExist) {}
66
>bet : Symbol(Q.bet, Decl(accessorDeclarationEmitVisibilityErrors.ts, 0, 16))
77
>arg : Symbol(arg, Decl(accessorDeclarationEmitVisibilityErrors.ts, 1, 12))
8+
>DoesNotExist : Symbol(DoesNotExist)
89
}

tests/baselines/reference/accessorDeclarationEmitVisibilityErrors.types

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ export class Q {
33
>Q : Q
44

55
set bet(arg: DoesNotExist) {}
6-
>bet : any
7-
>arg : any
6+
>bet : DoesNotExist
7+
>arg : DoesNotExist
88
}

tests/baselines/reference/aliasBug.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ function use() {
4444
var p3:booz.bar;
4545
>p3 : Symbol(p3, Decl(aliasBug.ts, 15, 5))
4646
>booz : Symbol(booz, Decl(aliasBug.ts, 7, 21))
47+
>bar : Symbol(booz.bar)
4748

4849
var p22 = new provide.Provide();
4950
>p22 : Symbol(p22, Decl(aliasBug.ts, 16, 5))

tests/baselines/reference/aliasBug.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ function use() {
4141
>foo : any
4242

4343
var p3:booz.bar;
44-
>p3 : any
44+
>p3 : booz.bar
4545
>booz : any
4646

4747
var p22 = new provide.Provide();

tests/baselines/reference/aliasErrors.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ function use() {
7474
var p3:booz.bar;
7575
>p3 : Symbol(p3, Decl(aliasErrors.ts, 25, 5))
7676
>booz : Symbol(booz, Decl(aliasErrors.ts, 6, 21))
77+
>bar : Symbol(booz.bar)
7778

7879
var p22 = new provide.Provide();
7980
>p22 : Symbol(p22, Decl(aliasErrors.ts, 26, 5))

tests/baselines/reference/aliasErrors.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function use() {
8181
>foo : any
8282

8383
var p3:booz.bar;
84-
>p3 : any
84+
>p3 : booz.bar
8585
>booz : any
8686

8787
var p22 = new provide.Provide();

tests/baselines/reference/allowImportClausesToMergeWithTypes.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,6 @@ originalZZZ;
4747

4848
const y: originalZZZ = x;
4949
>y : Symbol(y, Decl(index.ts, 8, 5))
50+
>originalZZZ : Symbol(originalZZZ)
5051
>x : Symbol(x, Decl(index.ts, 2, 5))
5152

tests/baselines/reference/allowImportClausesToMergeWithTypes.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,6 @@ originalZZZ;
4848
>originalZZZ : 123
4949

5050
const y: originalZZZ = x;
51-
>y : any
51+
>y : originalZZZ
5252
>x : zzz
5353

tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.symbols

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ declare module "OuterModule" {
1717
public x: m2.c;
1818
>x : Symbol(SubModule.x, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 4, 35))
1919
>m2 : Symbol(m2, Decl(ambientExternalModuleWithRelativeExternalImportDeclaration.ts, 0, 30))
20-
>c : Symbol(m2)
20+
>c : Symbol(m2.c)
2121

2222
constructor();
2323
}

tests/baselines/reference/ambientExternalModuleWithRelativeExternalImportDeclaration.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ declare module "OuterModule" {
1515
>InstanceVar : number
1616

1717
public x: m2.c;
18-
>x : any
18+
>x : m2.c
1919
>m2 : any
2020

2121
constructor();

tests/baselines/reference/assertionFunctionsCanNarrowByDiscriminant.symbols

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ assertEqual(animal.type, 'cat' as const);
4444
>animal.type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
4545
>animal : Symbol(animal, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 14, 5))
4646
>type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
47+
>const : Symbol(const)
4748

4849
animal.canMeow; // since is cat, should not be an error
4950
>animal.canMeow : Symbol(Cat.canMeow, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 1, 16))
@@ -61,6 +62,7 @@ assertEqual(animalOrUndef?.type, 'cat' as const);
6162
>animalOrUndef?.type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
6263
>animalOrUndef : Symbol(animalOrUndef, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 19, 5))
6364
>type : Symbol(type, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 0, 15), Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 5, 15))
65+
>const : Symbol(const)
6466

6567
animalOrUndef.canMeow; // since is cat, should not be an error
6668
>animalOrUndef.canMeow : Symbol(Cat.canMeow, Decl(assertionFunctionsCanNarrowByDiscriminant.ts, 1, 16))

tests/baselines/reference/assignmentCompatWithStringIndexer3.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ interface Derived2 extends Derived { baz: string; }
1717

1818
var a: A;
1919
>a : Symbol(a, Decl(assignmentCompatWithStringIndexer3.ts, 6, 3))
20+
>A : Symbol(A)
2021

2122
var b1: { [x: string]: string; }
2223
>b1 : Symbol(b1, Decl(assignmentCompatWithStringIndexer3.ts, 7, 3))

tests/baselines/reference/assignmentCompatWithStringIndexer3.types

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,21 @@ interface Derived2 extends Derived { baz: string; }
1111
>baz : string
1212

1313
var a: A;
14-
>a : any
14+
>a : A
1515

1616
var b1: { [x: string]: string; }
1717
>b1 : { [x: string]: string; }
1818
>x : string
1919

2020
a = b1; // error
2121
>a = b1 : { [x: string]: string; }
22-
>a : any
22+
>a : A
2323
>b1 : { [x: string]: string; }
2424

2525
b1 = a; // error
26-
>b1 = a : any
26+
>b1 = a : A
2727
>b1 : { [x: string]: string; }
28-
>a : any
28+
>a : A
2929

3030
module Generics {
3131
>Generics : typeof Generics

tests/baselines/reference/asyncArrowFunction10_es2017.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ var foo = async (): Promise<void> => {
66
// Legal to use 'await' in a type context.
77
var v: await;
88
>v : Symbol(v, Decl(asyncArrowFunction10_es2017.ts, 2, 6))
9+
>await : Symbol(await)
910
}
1011

tests/baselines/reference/asyncArrowFunction10_es2017.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ var foo = async (): Promise<void> => {
55

66
// Legal to use 'await' in a type context.
77
var v: await;
8-
>v : any
8+
>v : await
99
}
1010

tests/baselines/reference/asyncArrowFunction10_es5.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ var foo = async (): Promise<void> => {
66
// Legal to use 'await' in a type context.
77
var v: await;
88
>v : Symbol(v, Decl(asyncArrowFunction10_es5.ts, 2, 6))
9+
>await : Symbol(await)
910
}
1011

tests/baselines/reference/asyncArrowFunction10_es5.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ var foo = async (): Promise<void> => {
55

66
// Legal to use 'await' in a type context.
77
var v: await;
8-
>v : any
8+
>v : await
99
}
1010

tests/baselines/reference/asyncArrowFunction10_es6.symbols

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ var foo = async (): Promise<void> => {
66
// Legal to use 'await' in a type context.
77
var v: await;
88
>v : Symbol(v, Decl(asyncArrowFunction10_es6.ts, 2, 6))
9+
>await : Symbol(await)
910
}
1011

tests/baselines/reference/asyncArrowFunction10_es6.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ var foo = async (): Promise<void> => {
55

66
// Legal to use 'await' in a type context.
77
var v: await;
8-
>v : any
8+
>v : await
99
}
1010

0 commit comments

Comments
 (0)