microsoft / microsoft/TypeScript
A way to expand mapped types
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.3k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con el manejo de IntelliSense de language-service de TypeScript para tipos mapeados y condicionales, usando el ejemplo de Mapper de este issue como reproducción. Determina cómo debería exponer sus propiedades resueltas el tipo mapeado mostrado; se considera terminado cuando IntelliSense presenta la estructura expandida de session en lugar de solo el mapper y el tipo original.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- developer-experience
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 35/100