Closed
Description
TypeScript Version: 2.2.2
Code
interface List<T> {
add(elem: T): void
}
function map(list: List<number>): List<number | null> {
return list;
}
function foo(list: List<number>) {
map(list).add(null);
}
Expected behavior:
Compiler should complain about line 6 (return list
) when strictNullChecks
is enabled, because add(elem: number): void
has a different signature than add(elem: (number | null)): void
.
Actual behavior:
This above code goes through the compiler, even though strictNullChecks
, noImplicitAny
et c. are all enabled. This results in that we can add null
to a List<Number>
in function foo
and the compiler does not complain.