2016-10-06 22:27:18 +02:00
|
|
|
// @strictNullChecks: true
|
|
|
|
|
2017-04-05 20:06:14 +02:00
|
|
|
// Fixes #10501, possibly null 'x'
|
2016-10-06 22:27:18 +02:00
|
|
|
function f() {
|
|
|
|
const x: string | null = <any>{};
|
|
|
|
if (x !== null) {
|
|
|
|
return {
|
2017-04-05 20:06:14 +02:00
|
|
|
bar() { return x.length; } // ok
|
2016-10-06 22:27:18 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function f2() {
|
|
|
|
const x: string | null = <any>{};
|
|
|
|
if (x !== null) {
|
|
|
|
return class {
|
2017-04-05 20:06:14 +02:00
|
|
|
bar() { return x.length; } // ok
|
2016-10-06 22:27:18 +02:00
|
|
|
};
|
|
|
|
}
|
2017-04-05 20:06:14 +02:00
|
|
|
}
|