microsoft / microsoft/TypeScript
`tsserver` feature: `importModuleSpecifierPreference: "non-relative"` but allow siblings
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
importModuleSpecifierPreference
allow sibling
✅ 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
Let auto-imports mirror:
https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-relative-parent-imports.md
or the old:
https://github.com/microsoft/tslint-microsoft-contrib/issues/778
New option, could be named anything, "non-relative-allow-sibling", "no-parent", "relative-iff-sibling", etc
📃 Motivating Example
re: "why this feature improves the language", this is not a language feature, but an IDE feature which happens to be handled by TypeScript repo:
Motivating example: When you auto-import, you want to import as ./foo if in same directory, otherwise something like @/utils/foo. shortest doesn't necessarily work since ../foo could be shorter than e.g. @/modules/feature/foo
💻 Use Cases
Currently using importModuleSpecifierPreference: "non-relative" as-is.
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 dalla definizione di importModuleSpecifierPreference in src/server/protocol.ts nella posizione collegata, quindi segui il modo in cui tsserver sceglie gli specifier per gli import automatici. Definisci che i file fratelli devono usare ./foo, mentre gli altri import devono rimanere non relativi, e individua i test pertinenti per gli import automatici prima di implementare e convalidare la nuova opzione.
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
- 25/100