microsoft / microsoft/TypeScript
A new generic type can be used for file path completion(intellisense)
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
🔍 Search Terms
"path intellisense","path completion","asset path completion"
✅ Viability Checklist
- 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 isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
⭐ Suggestion
Add a tool generics so that some function parameters can enable file path type hints
some assets in ../assets
function getImageUrl(name:T<"../assets">) {
...
return ...
}
getImageUrl("// intellisense
📃 Motivating Example
Enable custom file path completion through generics
💻 Use Cases
- What do you want to use this for?
When I used vite static resource introduction, I used a function to wrap it, but the function parameters could not achieve type hints like import.
the function like:
function getImageUrl(name:string) { // lost file intellisense
return new URL(`./dir/${name}.png`, import.meta.url).href
}
- What shortcomings exist with current approaches?
Only import statements support path completion and cannot be customized
- What workarounds are you using in the meantime?
i make a vscode extension
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 con la sintassi del tipo generico richiesta e confrontala con il completamento dei percorsi già disponibile nelle istruzioni di importazione. Esamina l’esempio di asset-wrapper di Vite e la soluzione alternativa segnalata per l’estensione VS Code; il lavoro sarà completato quando i parametri delle funzioni personalizzate forniranno il completamento dei percorsi degli asset senza modificare il JavaScript emesso né il comportamento a runtime.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- developer-experience
- Tipo di issue
- Funzionalità
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100