microsoft / microsoft/TypeScript
A way to expand mapped types
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
I want to be able to expand mapped type in intellisense
Currently, mapped types is displayed directly with the mapper and original type, which is unhelpful as hell

With the ts 2.8 condition type,
you can write more powerful declaration to map almost everything to correct type for you,
but the ide simply show it is mapped,
you don't know what is it actually mapped to.
for example, in the above case, I have a mapper looks like
type Mapper<T> = {
[K in keyof T]:
T[K] extends {type: SQL_ENUM<infer U>}? U:
T[K] extends {type: SQL_ENUM<infer U>, allowNull: true}? U | undefined:
T[K] extends {type: typeof Sequelize.DATE, allowNull: true}? Date | undefined:
T[K] extends {type: typeof Sequelize.DATE}? Date:
T[K] extends {type: typeof Sequelize.INTEGER, allowNull: true}? number | undefined:
T[K] extends {type: typeof Sequelize.INTEGER}? number:
// stop here, fon't let things goes too wrong
T[K] extends {type: typeof Sequelize.ENUM}? never:
T[K] extends {type: typeof Sequelize.STRING, allowNull: true}? string | undefined:
T[K] extends {type: typeof Sequelize.STRING}? string:
T[K] extends {type: typeof Sequelize.TEXT, allowNull: true}? string | undefined:
T[K] extends {type: typeof Sequelize.TEXT}? string:
T[K] extends {type: typeof Sequelize.BOOLEAN, allowNull: true}? boolean | undefined:
T[K] extends {type: typeof Sequelize.BOOLEAN}? boolean:
any
}
that will transform the decalration to a simple
interface session {
token: string,
userId: string,
ip: string
}
But the ide won't tell you anything, which is quite annoying
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with TypeScript's language-service IntelliSense handling for mapped and conditional types, using the Mapper example in this issue as the reproduction. Determine how the displayed mapped type should expose its resolved properties; done means IntelliSense presents the expanded session shape rather than only the mapper and original type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100