|
| 1 | +=== tests/cases/compiler/strictNullNotNullIndexTypeNoLib.ts === |
| 2 | +type Readonly<T> = {readonly [K in keyof T]: T[K]} |
| 3 | +>Readonly : Symbol(Readonly, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 0)) |
| 4 | +>T : Symbol(T, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 14)) |
| 5 | +>K : Symbol(K, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 30)) |
| 6 | +>T : Symbol(T, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 14)) |
| 7 | +>T : Symbol(T, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 14)) |
| 8 | +>K : Symbol(K, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 30)) |
| 9 | + |
| 10 | +interface A { |
| 11 | +>A : Symbol(A, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 50)) |
| 12 | + |
| 13 | + params?: { name: string; }; |
| 14 | +>params : Symbol(A.params, Decl(strictNullNotNullIndexTypeNoLib.ts, 1, 13)) |
| 15 | +>name : Symbol(name, Decl(strictNullNotNullIndexTypeNoLib.ts, 2, 14)) |
| 16 | +} |
| 17 | + |
| 18 | +class Test<T extends A> { |
| 19 | +>Test : Symbol(Test, Decl(strictNullNotNullIndexTypeNoLib.ts, 3, 1)) |
| 20 | +>T : Symbol(T, Decl(strictNullNotNullIndexTypeNoLib.ts, 5, 11)) |
| 21 | +>A : Symbol(A, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 50)) |
| 22 | + |
| 23 | + attrs: Readonly<T>; |
| 24 | +>attrs : Symbol(Test.attrs, Decl(strictNullNotNullIndexTypeNoLib.ts, 5, 25)) |
| 25 | +>Readonly : Symbol(Readonly, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 0)) |
| 26 | +>T : Symbol(T, Decl(strictNullNotNullIndexTypeNoLib.ts, 5, 11)) |
| 27 | + |
| 28 | + m() { |
| 29 | +>m : Symbol(Test.m, Decl(strictNullNotNullIndexTypeNoLib.ts, 6, 23)) |
| 30 | + |
| 31 | + this.attrs.params!.name; |
| 32 | +>this.attrs.params : Symbol(params, Decl(strictNullNotNullIndexTypeNoLib.ts, 1, 13)) |
| 33 | +>this.attrs : Symbol(Test.attrs, Decl(strictNullNotNullIndexTypeNoLib.ts, 5, 25)) |
| 34 | +>this : Symbol(Test, Decl(strictNullNotNullIndexTypeNoLib.ts, 3, 1)) |
| 35 | +>attrs : Symbol(Test.attrs, Decl(strictNullNotNullIndexTypeNoLib.ts, 5, 25)) |
| 36 | +>params : Symbol(params, Decl(strictNullNotNullIndexTypeNoLib.ts, 1, 13)) |
| 37 | + } |
| 38 | +} |
| 39 | + |
| 40 | +interface Foo { |
| 41 | +>Foo : Symbol(Foo, Decl(strictNullNotNullIndexTypeNoLib.ts, 11, 1)) |
| 42 | + |
| 43 | + foo?: number; |
| 44 | +>foo : Symbol(Foo.foo, Decl(strictNullNotNullIndexTypeNoLib.ts, 13, 15)) |
| 45 | +} |
| 46 | + |
| 47 | +class FooClass<P extends Foo = Foo> { |
| 48 | +>FooClass : Symbol(FooClass, Decl(strictNullNotNullIndexTypeNoLib.ts, 15, 1)) |
| 49 | +>P : Symbol(P, Decl(strictNullNotNullIndexTypeNoLib.ts, 17, 15)) |
| 50 | +>Foo : Symbol(Foo, Decl(strictNullNotNullIndexTypeNoLib.ts, 11, 1)) |
| 51 | +>Foo : Symbol(Foo, Decl(strictNullNotNullIndexTypeNoLib.ts, 11, 1)) |
| 52 | + |
| 53 | + properties: Readonly<P>; |
| 54 | +>properties : Symbol(FooClass.properties, Decl(strictNullNotNullIndexTypeNoLib.ts, 17, 37)) |
| 55 | +>Readonly : Symbol(Readonly, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 0)) |
| 56 | +>P : Symbol(P, Decl(strictNullNotNullIndexTypeNoLib.ts, 17, 15)) |
| 57 | + |
| 58 | + foo(): number { |
| 59 | +>foo : Symbol(FooClass.foo, Decl(strictNullNotNullIndexTypeNoLib.ts, 18, 28)) |
| 60 | + |
| 61 | + const { foo = 42 } = this.properties; |
| 62 | +>foo : Symbol(foo, Decl(strictNullNotNullIndexTypeNoLib.ts, 21, 15)) |
| 63 | +>this.properties : Symbol(FooClass.properties, Decl(strictNullNotNullIndexTypeNoLib.ts, 17, 37)) |
| 64 | +>this : Symbol(FooClass, Decl(strictNullNotNullIndexTypeNoLib.ts, 15, 1)) |
| 65 | +>properties : Symbol(FooClass.properties, Decl(strictNullNotNullIndexTypeNoLib.ts, 17, 37)) |
| 66 | + |
| 67 | + return foo; |
| 68 | +>foo : Symbol(foo, Decl(strictNullNotNullIndexTypeNoLib.ts, 21, 15)) |
| 69 | + } |
| 70 | +} |
| 71 | + |
| 72 | +class Test2<T extends A> { |
| 73 | +>Test2 : Symbol(Test2, Decl(strictNullNotNullIndexTypeNoLib.ts, 24, 1)) |
| 74 | +>T : Symbol(T, Decl(strictNullNotNullIndexTypeNoLib.ts, 26, 12)) |
| 75 | +>A : Symbol(A, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 50)) |
| 76 | + |
| 77 | + attrs: Readonly<T>; |
| 78 | +>attrs : Symbol(Test2.attrs, Decl(strictNullNotNullIndexTypeNoLib.ts, 26, 26)) |
| 79 | +>Readonly : Symbol(Readonly, Decl(strictNullNotNullIndexTypeNoLib.ts, 0, 0)) |
| 80 | +>T : Symbol(T, Decl(strictNullNotNullIndexTypeNoLib.ts, 26, 12)) |
| 81 | + |
| 82 | + m() { |
| 83 | +>m : Symbol(Test2.m, Decl(strictNullNotNullIndexTypeNoLib.ts, 27, 23)) |
| 84 | + |
| 85 | + return this.attrs.params!; // Return type should maintain relationship with `T` after being not-null-asserted, ideally |
| 86 | +>this.attrs.params : Symbol(params, Decl(strictNullNotNullIndexTypeNoLib.ts, 1, 13)) |
| 87 | +>this.attrs : Symbol(Test2.attrs, Decl(strictNullNotNullIndexTypeNoLib.ts, 26, 26)) |
| 88 | +>this : Symbol(Test2, Decl(strictNullNotNullIndexTypeNoLib.ts, 24, 1)) |
| 89 | +>attrs : Symbol(Test2.attrs, Decl(strictNullNotNullIndexTypeNoLib.ts, 26, 26)) |
| 90 | +>params : Symbol(params, Decl(strictNullNotNullIndexTypeNoLib.ts, 1, 13)) |
| 91 | + } |
| 92 | +} |
0 commit comments