-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Open
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Mapped TypesThe issue relates to mapped typesThe issue relates to mapped types
Milestone
Description
TypeScript Version: 3.3.3333
Search Terms: NonPartial, remove optional modifier
Code
// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
interface OptClass {
opt?: number;
}
type NonPartialIsh = {[K in keyof OptClass]-?: OptClass[K] | undefined};
const test = {opt: undefined};
verify<NonPartialIsh>(test); // should NOT be error, but shows error
function verify<T>(a: T) {}Expected behavior:
- Should not have any error.
NonPartialish.opttype should supportundefined.
Actual behavior:
- Throws the following error:
ERROR(12,23): : Argument of type '{ opt: undefined; }' is not assignable to parameter of type 'NonPartialIsh'.
Types of property 'opt' are incompatible.
Type 'undefined' is not assignable to type 'number'.
Transpiled code follows despite errors.
NonPartialish.opttype does not supportundefined.
Related Issues:
matthias-ccri, ekilah, TheUnlocked, liuliangsir, richardscarrott and 6 more
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: Mapped TypesThe issue relates to mapped typesThe issue relates to mapped types