20 lines
405 B
TypeScript
20 lines
405 B
TypeScript
// @strictNullChecks: true
|
|
|
|
// Fixes #10501, possibly null 'x'
|
|
function f() {
|
|
const x: string | null = <any>{};
|
|
if (x !== null) {
|
|
return {
|
|
bar() { return x.length; } // ok
|
|
};
|
|
}
|
|
}
|
|
|
|
function f2() {
|
|
const x: string | null = <any>{};
|
|
if (x !== null) {
|
|
return class {
|
|
bar() { return x.length; } // ok
|
|
};
|
|
}
|
|
}
|