* Don't reset CFA type for x.y when x is narrowed * Add tests * Accept new baselines * Remove unnecessary type assertion
34 lines
579 B
TypeScript
34 lines
579 B
TypeScript
// @strict: true
|
|
|
|
// Repro from #36709
|
|
|
|
class A {
|
|
constructor(public stringOrUndefined: string | undefined) {}
|
|
}
|
|
|
|
class B {
|
|
constructor(public str: string) {}
|
|
}
|
|
|
|
const a = new A("123");
|
|
|
|
if (a instanceof A && a.stringOrUndefined) {
|
|
new B(a.stringOrUndefined)
|
|
}
|
|
|
|
if (a.stringOrUndefined && a instanceof A) {
|
|
new B(a.stringOrUndefined)
|
|
}
|
|
|
|
if (a instanceof A) {
|
|
if (a.stringOrUndefined) {
|
|
new B(a.stringOrUndefined)
|
|
}
|
|
}
|
|
|
|
if (a.stringOrUndefined) {
|
|
if (a instanceof A) {
|
|
new B(a.stringOrUndefined)
|
|
}
|
|
}
|