-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug
Description
TypeScript Version: 2.2.0
--strictNullChecks
must be used.
Code
interface Foo {
name: () => string;
}
let foo: Foo;
setTimeout((() => foo.name()), 0);
Expected behavior:
Error at let foo: Foo
line since the compiler is implicitly doing let foo: Foo = undefined;
.
If I were to write the = undefined
initializer myself, the compiler properly errors with:
Type 'undefined' is not assignable to type 'Foo'.
Actual behavior:
The code compiles and errors at runtime:
TypeError: foo is undefined
patrickhulce, wwwillchen, alex1001xela and farzher
Metadata
Metadata
Assignees
Labels
Working as IntendedThe behavior described is the intended behavior; this is not a bugThe behavior described is the intended behavior; this is not a bug