@@ -136,34 +136,36 @@ type R = { foo: string }
136
136
export class C {
137
137
>C : Symbol(C, Decl(assertToOtherTypes.ts, 4, 24))
138
138
139
+ // under !strictNullChecks all types can be reused from the assertion
140
+ // under strictNullChecks we need to add undefined, and we can't always know we can
139
141
// Can't know if references contain undefined, fall back to inference
140
142
tsResolve? = null! as R | R;
141
143
>tsResolve : Symbol(C.tsResolve, Decl(assertToOtherTypes.ts, 6, 16))
142
144
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
143
145
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
144
146
145
147
tsResolve2? = null! as R | R | string;
146
- >tsResolve2 : Symbol(C.tsResolve2, Decl(assertToOtherTypes.ts, 8 , 32))
148
+ >tsResolve2 : Symbol(C.tsResolve2, Decl(assertToOtherTypes.ts, 10 , 32))
147
149
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
148
150
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
149
151
150
152
// Simple type. we can add undefined
151
153
reuseType? = null! as ((p: R) => void) | string | string;
152
- >reuseType : Symbol(C.reuseType, Decl(assertToOtherTypes.ts, 9 , 42))
153
- >p : Symbol(p, Decl(assertToOtherTypes.ts, 11 , 28))
154
+ >reuseType : Symbol(C.reuseType, Decl(assertToOtherTypes.ts, 11 , 42))
155
+ >p : Symbol(p, Decl(assertToOtherTypes.ts, 13 , 28))
154
156
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
155
157
156
158
reuseType2? = null! as (new (p: R) => R) | string | string;
157
- >reuseType2 : Symbol(C.reuseType2, Decl(assertToOtherTypes.ts, 11 , 61))
158
- >p : Symbol(p, Decl(assertToOtherTypes.ts, 12 , 33))
159
+ >reuseType2 : Symbol(C.reuseType2, Decl(assertToOtherTypes.ts, 13 , 61))
160
+ >p : Symbol(p, Decl(assertToOtherTypes.ts, 14 , 33))
159
161
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
160
162
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
161
163
162
164
reuseType3? = null! as string | number | bigint | symbol | unknown | any | never | symbol;
163
- >reuseType3 : Symbol(C.reuseType3, Decl(assertToOtherTypes.ts, 12 , 63))
165
+ >reuseType3 : Symbol(C.reuseType3, Decl(assertToOtherTypes.ts, 14 , 63))
164
166
165
167
reuseType4? = null! as [R, R, R] | [R, R, R];
166
- >reuseType4 : Symbol(C.reuseType4, Decl(assertToOtherTypes.ts, 13 , 94))
168
+ >reuseType4 : Symbol(C.reuseType4, Decl(assertToOtherTypes.ts, 15 , 94))
167
169
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
168
170
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
169
171
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
@@ -172,19 +174,19 @@ export class C {
172
174
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
173
175
174
176
reuseType5? = null! as R[] | R[];
175
- >reuseType5 : Symbol(C.reuseType5, Decl(assertToOtherTypes.ts, 14 , 49))
177
+ >reuseType5 : Symbol(C.reuseType5, Decl(assertToOtherTypes.ts, 16 , 49))
176
178
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
177
179
>R : Symbol(R, Decl(assertToOtherTypes.ts, 2, 42))
178
180
179
181
reuseType6? = null! as 1 | "2" | 1n | 1n;
180
- >reuseType6 : Symbol(C.reuseType6, Decl(assertToOtherTypes.ts, 15 , 37))
182
+ >reuseType6 : Symbol(C.reuseType6, Decl(assertToOtherTypes.ts, 17 , 37))
181
183
182
184
reuseType7? = null! as `A` | `A`;
183
- >reuseType7 : Symbol(C.reuseType7, Decl(assertToOtherTypes.ts, 16 , 45))
185
+ >reuseType7 : Symbol(C.reuseType7, Decl(assertToOtherTypes.ts, 18 , 45))
184
186
185
187
reuseType8? = null! as `${string}-ok` | `${string}-ok`;
186
- >reuseType8 : Symbol(C.reuseType8, Decl(assertToOtherTypes.ts, 17 , 37))
188
+ >reuseType8 : Symbol(C.reuseType8, Decl(assertToOtherTypes.ts, 19 , 37))
187
189
188
190
reuseType9? = null! as this | this;
189
- >reuseType9 : Symbol(C.reuseType9, Decl(assertToOtherTypes.ts, 18 , 59))
191
+ >reuseType9 : Symbol(C.reuseType9, Decl(assertToOtherTypes.ts, 20 , 59))
190
192
}
0 commit comments