Open
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.opt
type 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.opt
type does not supportundefined
.
Related Issues: