microsoft / microsoft/TypeScript
Allow `infer function return type` refactor when return type are not imported
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.4k
- Merge medio
- 1g 19h
- PR unite (30g)
- 117
Descrizione
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.

Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia riproducendo il refactoring infer function return type con una funzione il cui oggetto restituito usa tipi che non sono importati. Esamina il comportamento esistente del refactoring e determina quale gestione proposta sia appropriata: importare automaticamente i tipi mancanti, segnalarli oppure sostituirli con unknown. Il lavoro è completato quando il refactoring ha un comportamento definito per gli import mancanti e una copertura per il caso alla base del problema.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- developer-experience, tooling
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100