microsoft / microsoft/TypeScript
Allow `infer function return type` refactor when return type are not imported
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.4k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.

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 damit, das Refactoring infer function return type mit einer Funktion zu reproduzieren, deren zurückgegebenes Objekt Typen verwendet, die nicht importiert sind. Überprüfe das bestehende Verhalten des Refactorings und bestimme, welche der vorgeschlagenen Behandlungen angemessen ist: fehlende Typen automatisch importieren, sie melden oder sie durch unknown ersetzen. Als erledigt gilt die Aufgabe, wenn das Refactoring ein definiertes Verhalten für fehlende Importe sowie eine Abdeckung für den ausschlaggebenden Fall hat.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- developer-experience, tooling
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 35/100