Getting value/index types of generic mapped type
- Dominant language
- TypeScript
- Stars
- 6.2k
- Forks
- 238
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Description
Suppose I have a type
```typescript
type GenericMappedType = {
[K in T]: V;
}
```
If the type were
```typescript
type SimpleMappedType = Record;
```
I would be able to get the value type by using the method `Type.getStringIndexType()`. However, with the generic type, I don't see any way of doing something similar, or even finding out that `V` is the value type of the mapped type, and that `K`, which extends `T` is the index type.
It would be nice if there were a function like `MappedTypeNode.getIndexType()` and `MappedTypeNode.getValueType()` for this sort of type.
Contributor guide
Research direction
Start by inspecting the existing Type.getStringIndexType() API and the MappedTypeNode representation in ts-morph. Determine how the generic mapped type exposes its index and value types, then define and validate the proposed MappedTypeNode.getIndexType() and getValueType() behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- devtools
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100