-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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.1.4
Code
function f (offset: number) {}
let x = (offset = 0) => {
f(offset)
}
x = function (offset = 0) {
f(offset)
}{
"compilerOptions": {
"target": "es5",
"outDir": "dist",
"module": "commonjs",
"noImplicitAny": true,
"strictNullChecks": true
}
}Expected behavior: No error.
Actual behavior:
index.ts(8,5): error TS2345: Argument of type 'number | undefined' is not assignable to parameter of type 'number'.
Type 'undefined' is not assignable to type 'number'.
I believe this has actually been an issue in previous releases, but 2.1 has made it apparent in other argument positions. I just tested 2.0 and can reproduce the above sample, but it doesn't fail on 2.0 with (x: string, y = 0) whereas 2.1 does.
Reactions are currently unavailable
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