microsoft / microsoft/TypeScript

Allow `infer function return type` refactor when return type are not imported

Aperta
#45,040 1 commento 3 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
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.

image

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

image

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. 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

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.