This is my interface
interface X {
key: string
value: number | undefined
default?: number
}
But I want the non-optional keys only, aka. "key" | "value", or just "key" (both will do fine for me)
type KeyOfX = keyof X gives me "key" | "value" | "default".
type NonOptionalX = {
[P in keyof X]-?: X[P]
}
type NonOptionalKeyOfX = keyof NonOptionalX gives "key" | "value" | "default" as -? only removes the optional modifier and make all of them non-optional.
ps. I use Typescript 2.9.