microsoft / microsoft/TypeScript
A way to expand mapped types
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 2 T. 4 Std.
- Gemergte PRs (30 T.)
- 132
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der IntelliSense-Verarbeitung von TypeScript's language-service für gemappte und bedingte Typen und verwende dabei das Mapper-Beispiel in diesem Issue als Reproduktion. Ermittle, wie der angezeigte gemappte Typ seine aufgelösten Eigenschaften offenlegen sollte; abgeschlossen ist dies, wenn IntelliSense die erweiterte Session-Struktur statt nur des Mappers und des ursprünglichen Typs präsentiert.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- developer-experience
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100