Exclude from string results string
I would like to define a type where all the attributes are read only and looks like key:string value:string, but the 'set' attribute is a function.
I have tried the following:
type Attributes = {
readonly [key in Exclude<string, 'set'>]:string
} & {
readonly set: (attr:string, value:string) => void
}
My problem is Exclude<string, 'set'>
is "simplified" back into string
. Could someone with more experience explain why TypeScript does this? Some suggestions how to achive a type where I know only few property keys (but there can be many more) could help me out.
Thank you for your time and answers!
from Recent Questions - Stack Overflow https://ift.tt/2WvkZSE
https://ift.tt/eA8V8J
Comments
Post a Comment