Closed
Description
// @strictNullChecks: true
interface Data {
data: any
}
declare const value: Data | undefined;
function doSthWithValue(v: undefined): undefined;
function doSthWithValue(v: Data): Data;
function doSthWithValue(v?: Data) {
return v;
}
const a = doSthWithValue(value); // <-- error
EDIT: see comment below, it is not connected to strictNullChecks
Expected behavior:
Should not throw error with strictNullChecks
enabled
Actual behavior:
It throws error:
Argument of type 'Data | undefined' is not assignable to parameter of type 'undefined'.
Type 'Data' is not assignable to type 'undefined'.
Playground Link:
Enable strictNullChecks
. The order of overloaded signatures does not change anything
Related issues:
#14107
Metadata
Metadata
Assignees
Labels
No labels