Closed
Description
TypeScript Version: Version 1.9.0-dev.20160610-1.0
Code
var foo: (baz?: string) => string;
foo = function watwat(baz: string): string {
return baz.toString();
};
foo(undefined);
Expected behavior:
Expected "Cannot call foo() with undefined"
Actual behavior:
No errors output.
When running node wat.js
we get an expected uncaught exception
/home/raynos/projects/http-hash-server/lib/wat.js:3
return baz.toString();
^
TypeError: Cannot call method 'toString' of undefined
My actual production use case is more complicated and involves assigning interfaces into a generic container class where the generic container class has an interface with optional arguments and the instance of the class that as#to the container has methods with non-optional arguments.
I expected that the structural equality checker would fail for optional arguments vs non-optional arguments when --strictNullChecks
is enabled.