basarat / basarat/typescript-book
Questions about section "Index Signatures"
- Dominant language
- TypeScript
- Stars
- 21.6k
- Forks
- 2.6k
- PR merge metrics
- No merged PRs in 30d
Description
This [chapter](https://basarat.gitbook.io/typescript/type-system/index-signatures) 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 }
```
Contributor guide
Research direction
Start with the linked "Index Signatures" chapter and inspect the FieldState/FormState intersection example. Verify how the chapter currently explains intersection and union types, then clarify why the proposed union alternative and the inferred result for incompatible intersections behave as they do. Done means the chapter answers both questions clearly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100