microsoft / microsoft/TypeScript
Show both narrowed type and declared type
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Go
- Estrellas
- 111k
- Forks
- 14.4k
- Merge medio
- 1 d 19 h
- PR fusionados (30 d)
- 117
Descripción
Suggestion
🔍 Search Terms
List of keywords you searched for before creating this issue. Write them down here so that others can find this suggestion more easily and help provide feedback.
✅ Viability Checklist
My suggestion meets these guidelines:
- This wouldn't be a breaking change in existing TypeScript/JavaScript code
- This wouldn't change the runtime behavior of existing JavaScript code
- This could be implemented without emitting different JS based on the types of the expressions
- This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- This feature would agree with the rest of TypeScript's Design Goals.
⭐ Suggestion
📃 Motivating Example
https://twitter.com/Rich_Harris/status/1437490023763415043
is roughly a confusion on narrowed vs storage type of a given field/binding
// _: any
let _;
// _: any
_ = new Date();
// _: any, but completions from Date
// type doesn't match usability, only assignability
_.getFullYear();
💻 Use Cases
Current UI / typing only shows what can be assigned to a value storage location given a source text location.
Need UI to show what can be used from a value storage location given a source text location.
Much of the time these should be the same but showing something about the narrowing would apparently remove some confusions, for example (bikeshed):
let _;
_ = new Date();
// _: any
_;
// becomes...
// _: any as Date
_;
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 los ejemplos motivadores y la descripción del comportamiento actual de la UI y del tipado. Determina cómo debe funcionar la visualización solicitada tanto del tipo de almacenamiento declarado como del tipo estrechado, y utiliza los ejemplos para definir cuándo está completa la funcionalidad.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, typescript
- Área
- compilers, developer-experience
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100