-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue
Milestone
Description
TypeScript Version: 2.2.0-dev.20170130 (npm version) / master
Code
interface Bar { bar: number; foo: object | null; }
let a = {
test<K extends keyof Bar> (a: K, b?: Bar[K] | null) {
console.log(a, b);
}
};
a.test("bar", null);Expected behavior:
tsc --strictNullChecks compiles it without errors.
Actual behavior:
It reports:
error TS2345: Argument of type 'null' is not assignable to parameter of type 'number | undefin
ed'.
Notes
This case only occurs if at least one member of Bar can be null and --strictNullChecks is enabled.
I think the checker should not merge null and undefined in optional union-type args.
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFixedA PR has been merged for this issueA PR has been merged for this issue