Closed
Description
TypeScript Version: 2.1.4
Code:
// --strictNullChecks
enum Enum1 {
A,
B
}
enum Enum2 {
A
}
interface Foo {
readonly kind: Enum1
}
interface Bar {
readonly kind: Enum2
}
let f = (x: Foo): number => {
switch (x.kind) {
case Enum1.A:
return 1;
case Enum1.B:
return 2;
}
}
let g = (x: Bar): number => {
switch (x.kind) {
case Enum2.A:
return 1;
}
}
Expected behaviour (as far as I know):
Compiles without error
Actual behaviour:
Function g
does not compile, with error TS2366: Function lacks ending return statement and return type does not include 'undefined'.
.
Without strict null checks, it compiles without error.