microsoft / microsoft/TypeScript

Code completion: suggest tokens from "paths" in tsconfig.json

Offen
#32,215 1 Kommentar 2 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

In Discussion Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

Search Terms

Code completion; module

Suggestion

Use Cases

For those paths which contains no wildcard character, can we suggest tokens from module it points?

For example:

{
  "baseUrl": '.',
  "paths": {
    "my-base-module": [
        "../../dest/base"
    ],
}

in the example, we can say that bare module specifier "my-base-module" is mapped to path "../../dest/base", which is actually a .d.ts.

However, my IDE(Visual Studio Code) do not list available symbols in "my-base-module",
such as, When I type:

const v: Ve // I 'm going to type Vec3, which is defined in "../../dest/base".

I hopo IDE can suggest Vec3 and auto-complete the importing statement as:

import { Vec3 } from "my-base-module";

You may ask: Why don't you put "../../dest/base" in "types" option in tsconfig.json.

Well, the "../../dest/base" is just a library of me. It is indeed another Typescript project's output bundle file(bundling use rollup). It is bundled as a single module, which, in later, maybe registered as a SystemJS module with name "my-base-module" because I hope users of the library treat the library as a single JS module so they can write:

import /* xx */ from "my-base-module";

Examples

As stated above, I would upload my example if it's needed.

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, etc.)
  • [-] This feature would agree with the rest of TypeScript's Design Goals.

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Das Issue enthält ein Beispiel für tsconfig.json-Pfade und ein TypeScript-Szenario zur Codevervollständigung, nennt jedoch keine Repository-Dateien oder Tests. Beginne damit, die fehlende Vervollständigung für Vec3 über das zugeordnete Bare-Modul zu reproduzieren; als erledigt gilt dies, wenn Symbole aus dem zugeordneten Bundle vorgeschlagen werden und der Import "my-base-module" verwendet.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
developer-experience
Issue-Typ
Feature
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
28/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.