microsoft / microsoft/TypeScript
`tsserver` feature: `importModuleSpecifierPreference: "non-relative"` but allow siblings
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
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.
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 mit der Definition von importModuleSpecifierPreference in src/server/protocol.ts an der verlinkten Stelle und verfolge anschließend, wie tsserver die Specifier für automatische Importe auswählt. Lege fest, dass Dateien im selben Verzeichnis ./foo verwenden sollen, während andere Importe nicht-relativ bleiben, und ermittle die relevanten Tests für automatische Importe, bevor du die neue Option implementierst und validierst.
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
- 25/100