1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
=== tests/cases/conformance/expressions/optionalChaining/optionalChainingInTypeAssertions.ts ===
class Foo {
>Foo : Symbol(Foo, Decl(optionalChainingInTypeAssertions.ts, 0, 0))
m() {}
>m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
}
const foo = new Foo();
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>Foo : Symbol(Foo, Decl(optionalChainingInTypeAssertions.ts, 0, 0))
(foo.m as any)?.();
>foo.m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
(<any>foo.m)?.();
>foo.m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
/*a1*/(/*a2*/foo.m as any/*a3*/)/*a4*/?.();
>foo.m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
/*b1*/(/*b2*/<any>foo.m/*b3*/)/*b4*/?.();
>foo.m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
// https://github.com/microsoft/TypeScript/issues/50148
(foo?.m as any).length;
>foo?.m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
(<any>foo?.m).length;
>foo?.m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>m : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
(foo?.["m"] as any).length;
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>"m" : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
(<any>foo?.["m"]).length;
>foo : Symbol(foo, Decl(optionalChainingInTypeAssertions.ts, 4, 5))
>"m" : Symbol(Foo.m, Decl(optionalChainingInTypeAssertions.ts, 0, 11))
|