microsoft / microsoft/TypeScript
Improve behavior of typescript.preferences.importModuleSpecifier: non-relative
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
Currently, with this setting"typescript.preferences.importModuleSpecifier": "non-relative" VScode goes to the tsconfig file and checks both baseUrl and paths and look for a match.
The situation that I experience is having a few paths in my path property and they sometimes overlap.
Example:
"baseUrl": ".",
"paths": {
"*": ["src/main/*"],
"utilsFunctions/*": ["src/main/utils/utilsFunctions*"],
},
With this configuration I can import a function from the utilsFunctions folder in one of these 2 options:
import { foo } from "src/main/utils/utilsFunctions/functions.tsimport { foo } from "utilsFunctions/functions.ts
Both of these import statements will work.
But If I add foo in my code without writing the import statement myself, vscode will auto-suggest me to use option no. 1, but In my case, I actually wanted option no.2 (in the above options).
Requested behavior:
When using foo (without it importing it first), VScode should suggest me both options.
My solution, in this case, was to reverse the order of paths like this:
"paths": {
"utilsFunctions/*": ["src/main/utils/utilsFunctions*"],
"*": ["src/main/*"],
},
🔍 Search Terms
importModuleSpecifier
✅ 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.
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, den Fall mit überlappendem tsconfig baseUrl und paths und auf non-relative gesetztem typescript.preferences.importModuleSpecifier zu reproduzieren. Verfolge, wie der Importvorschlag ausgewählt wird, und ermittle, wie beide gültigen Modul-Spezifizierer dargestellt werden sollten; abgeschlossen ist die Aufgabe, wenn die angeforderten Alternativen vorgeschlagen werden, ohne das bestehende Laufzeitverhalten zu ändern.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript, vscode
- 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