microsoft/TypeScript

Autocomplete should not suggest fields of type "never | undefined"

MastroLindus opened this issue · 3 comments

Sometimes types can have fields of type never|undefined to mark that those types shouldn't have that property:

type Test = {a: string, b?: never };

If that's the case, when using autocomplete to specify an object literal of that type, the fields marked as never|undefined shouldn't be suggested.

Currently autocomplete just requires us to get a single type. If we did this we would have to get the types of all of its properties, too, which could mean more work. I think an exact type {| a: string |} (#12936) would be a better solution than trying to specify every property that shouldn't exist.

@Andy-MS I completely agree. I opened this issue because when I opened #16679 it was suggested as a workaround/solution to mark fields as never. If that's the way to go, then I would argue that this issue would be necessary.

I was not aware that there was a proposal for exact types when I opened these 2 issues, and I agree that if those would get in the language, my use cases for this would be covered,

Does not seem that there has been a high demand for this request. closing for now.