TypeScript/tests/baselines/reference/variance.symbols
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

64 lines
2 KiB
Plaintext

=== tests/cases/conformance/types/conditional/variance.ts ===
// Test cases for parameter variances affected by conditional types.
// Repro from #30047
interface Foo<T> {
>Foo : Symbol(Foo, Decl(variance.ts, 0, 0))
>T : Symbol(T, Decl(variance.ts, 4, 14))
prop: T extends unknown ? true : false;
>prop : Symbol(Foo.prop, Decl(variance.ts, 4, 18))
>T : Symbol(T, Decl(variance.ts, 4, 14))
}
const foo = { prop: true } as const;
>foo : Symbol(foo, Decl(variance.ts, 8, 5))
>prop : Symbol(prop, Decl(variance.ts, 8, 13))
>const : Symbol(const)
const x: Foo<1> = foo;
>x : Symbol(x, Decl(variance.ts, 9, 5))
>Foo : Symbol(Foo, Decl(variance.ts, 0, 0))
>foo : Symbol(foo, Decl(variance.ts, 8, 5))
const y: Foo<number> = foo;
>y : Symbol(y, Decl(variance.ts, 10, 5))
>Foo : Symbol(Foo, Decl(variance.ts, 0, 0))
>foo : Symbol(foo, Decl(variance.ts, 8, 5))
const z: Foo<number> = x;
>z : Symbol(z, Decl(variance.ts, 11, 5))
>Foo : Symbol(Foo, Decl(variance.ts, 0, 0))
>x : Symbol(x, Decl(variance.ts, 9, 5))
// Repro from #30118
class Bar<T extends string> {
>Bar : Symbol(Bar, Decl(variance.ts, 11, 25))
>T : Symbol(T, Decl(variance.ts, 16, 10))
private static instance: Bar<string>[] = [];
>instance : Symbol(Bar.instance, Decl(variance.ts, 16, 29))
>Bar : Symbol(Bar, Decl(variance.ts, 11, 25))
cast(_name: ([T] extends [string] ? string : string)) { }
>cast : Symbol(Bar.cast, Decl(variance.ts, 17, 46))
>_name : Symbol(_name, Decl(variance.ts, 19, 7))
>T : Symbol(T, Decl(variance.ts, 16, 10))
pushThis() {
>pushThis : Symbol(Bar.pushThis, Decl(variance.ts, 19, 59))
Bar.instance.push(this);
>Bar.instance.push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>Bar.instance : Symbol(Bar.instance, Decl(variance.ts, 16, 29))
>Bar : Symbol(Bar, Decl(variance.ts, 11, 25))
>instance : Symbol(Bar.instance, Decl(variance.ts, 16, 29))
>push : Symbol(Array.push, Decl(lib.es5.d.ts, --, --))
>this : Symbol(Bar, Decl(variance.ts, 11, 25))
}
}