#Autocomplete not working while using Omit

1 messages · Page 1 of 1 (latest)

night osprey
#

Hi, I've encountered an unusual bug while using react-konva. Specifically, when I try to omit a property from the PathConfig interface, TypeScript's autocomplete stops working for the created type. I've set up a reproduction in TypeScript Playground. Autocomplete works correctly for "object1," but it doesn't work for "object2." Why is this happening?

sacred sleetBOT
#
golder303#0

Preview:```ts
interface Interface1 {
x?: number
y?: number
}

interface Interface2 extends Interface1 {
width?: number
height?: number
}

interface Interface3 extends Interface2 {
name?: string
}

interface NodeConfig {
[index: stri
...```

sly sierra
#

try inspecting Type2, it's just reduced to index signatures

#

Omit uses Pick with keyof T
keyof T on an index signature will yield string which collapses all the other keys

#

so the mapping only goes over string, so only the index signature is outputted

night osprey
#

Okay, now I understand, thank you very much.