microsoft / microsoft/TypeScript
Allow `infer function return type` refactor when return type are not imported
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
"infer function return type"
refactor
✅ 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
Infer function treturn type require all types used in return type are imported.
It takes a while to find which field is using a not imported type when returning many values as a object.
I want this refactor allowed by:
a. Auto import missing types
b. Show a message that tell user what is missing
c. Replace not imported type with unknown .
📃 Motivating Example
infer function return type refactor works when there is missing imports
💻 Use Cases
I'm extracting vue code to use composition api, with eslint rule @typescript-eslint/explicit-module-boundary-types enabled.
so i want use this refactor.
But infer function return type is not avaiable because some type not imported.

And i can not view all types because there is too many.

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 reproduciendo el refactor infer function return type con una función cuyo objeto devuelto usa tipos que no están importados. Revisa el comportamiento existente del refactor y determina cuál de los tratamientos propuestos es adecuado: importar automáticamente los tipos que faltan, informarlos o reemplazarlos por unknown. Se considera terminado cuando el refactor tiene un comportamiento definido para los imports que faltan y cobertura para el caso que lo motiva.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- typescript
- Área
- developer-experience, tooling
- 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