typescript-book icon indicating copy to clipboard operation
typescript-book copied to clipboard

Questions about section "Index Signatures"

Open JerryFan626 opened this issue 4 years ago • 0 comments

This chapter talks about: Using an intersection type to slove combine properties into index signature,but this is not useful. I have a question, Why not use Union Types(|) to combine this properties? And, Why TS is not infer "never" type, when you use intersection type(&) to merge two types that cannot possibly intersect.

type FieldState = {
  value: string
}

type FormState =
  { isValid: boolean }
  & { [fieldName: string]: FieldState }

JerryFan626 avatar Jan 14 '21 02:01 JerryFan626