Create a new type after deleting a property from object #42069
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
TypeScript Version: v4.13
Search Terms: delete property from object new type
Code
Expected behavior:
No type error should occur when calling
test
with the argumentbar
since we have deletedfoo
frombar
whenfoo
isnull
.Actual behavior:
The following error is reported by TS:
Argument of type 'ApiData' is not assignable to parameter of type 'Props'. Types of property 'foo' are incompatible. Type 'string | null | undefined' is not assignable to type 'string | undefined'. Type 'null' is not assignable to type 'string | undefined'.(2345)
Playground Link: https://www.typescriptlang.org/play?#code/JYOwLgpgTgZghgYwgAgIIAdgBE5jsgbwChlTkYB7CgfgC5kBnMKUAc2QB9kQBXAGz4BuIgF8iRUJFiIUABSgV0DQiTKUa9JixCthYojB4gEYYBRDJITABToFS+vMUMAlCrLIE5hhT4QAdHwUrLb2DP7qLnrI4l4gTMgARnBQ9BjYuPgAvO5qVPS8AqLiwDDI1slQEVTIWXXc-HxuxB4AJhB+kEkp1RR64lZgFSlRQA
Related Issues: #13783
The text was updated successfully, but these errors were encountered: