TypeScript/tests/baselines/reference/errorsInGenericTypeReference.types
Anders Hejlsberg a4f9bf0fce
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
2021-09-23 13:21:27 -07:00

143 lines
3.3 KiB
Plaintext

=== tests/cases/compiler/errorsInGenericTypeReference.ts ===
interface IFoo<T> { }
class Foo<T> { }
>Foo : Foo<T>
// in call type arguments
class testClass1 {
>testClass1 : testClass1
method<T>(): void { }
>method : <T>() => void
}
var tc1 = new testClass1();
>tc1 : testClass1
>new testClass1() : testClass1
>testClass1 : typeof testClass1
tc1.method<{ x: V }>(); // error: could not find symbol V
>tc1.method<{ x: V }>() : void
>tc1.method : <T>() => void
>tc1 : testClass1
>method : <T>() => void
>x : V
// in constructor type arguments
class testClass2<T> {
>testClass2 : testClass2<T>
}
var tc2 = new testClass2<{ x: V }>(); // error: could not find symbol V
>tc2 : testClass2<{ x: V; }>
>new testClass2<{ x: V }>() : testClass2<{ x: V; }>
>testClass2 : typeof testClass2
>x : V
// in method return type annotation
class testClass3 {
>testClass3 : testClass3
testMethod1(): Foo<{ x: V }> { return null; } // error: could not find symbol V
>testMethod1 : () => Foo<{ x: V;}>
>x : V
>null : null
static testMethod2(): Foo<{ x: V }> { return null } // error: could not find symbol V
>testMethod2 : () => Foo<{ x: V;}>
>x : V
>null : null
set a(value: Foo<{ x: V }>) { } // error: could not find symbol V
>a : Foo<{ x: V; }>
>value : Foo<{ x: V; }>
>x : V
property: Foo<{ x: V }>; // error: could not find symbol V
>property : Foo<{ x: V; }>
>x : V
}
// in function return type annotation
function testFunction1(): Foo<{ x: V }> { return null; } // error: could not find symbol V
>testFunction1 : () => Foo<{ x: V;}>
>x : V
>null : null
// in paramter types
function testFunction2(p: Foo<{ x: V }>) { }// error: could not find symbol V
>testFunction2 : (p: Foo<{ x: V;}>) => void
>p : Foo<{ x: V; }>
>x : V
// in var type annotation
var f: Foo<{ x: V }>; // error: could not find symbol V
>f : Foo<{ x: V; }>
>x : V
// in constraints
class testClass4<T extends { x: V }> { } // error: could not find symbol V
>testClass4 : testClass4<T>
>x : V
interface testClass5<T extends Foo<{ x: V }>> { } // error: could not find symbol V
>x : V
class testClass6<T> {
>testClass6 : testClass6<T>
method<M extends { x: V }>(): void { } // error: could not find symbol V
>method : <M extends { x: V; }>() => void
>x : V
}
interface testInterface1 {
new <M extends { x: V }>(a: M); // error: could not find symbol V
>x : V
>a : M
}
// in extends clause
class testClass7 extends Foo<{ x: V }> { } // error: could not find symbol V
>testClass7 : testClass7
>Foo : Foo<{ x: V; }>
>x : V
// in implements clause
class testClass8 implements IFoo<{ x: V }> { } // error: could not find symbol V
>testClass8 : testClass8
>x : V
// in signatures
interface testInterface2 {
new (a: Foo<{ x: V }>): Foo<{ x: V }>; //2x: error: could not find symbol V
>a : Foo<{ x: V; }>
>x : V
>x : V
[x: string]: Foo<{ x: V }>; // error: could not find symbol V
>x : string
>x : V
method(a: Foo<{ x: V }>): Foo<{ x: V }>; //2x: error: could not find symbol V
>method : (a: Foo<{ x: V;}>) => Foo<{ x: V;}>
>a : Foo<{ x: V; }>
>x : V
>x : V
property: Foo<{ x: V }>; // error: could not find symbol V
>property : Foo<{ x: V; }>
>x : V
}