microsoft / microsoft/TypeScript

Add API to query if SourceFile originated from typeRoots lookup

Offen
#26,684 3 Kommentare 3 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

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

Beschreibung

This proposes to add an API Program#isSourceFileFromTypeRoots that is similar to Program#isSourceFileFromExternalLibrary but for typeRoots.

Currently the only way to determine if a SourceFile comes from typeRoots is to use ts.getEffectiveTypeRoots and check if a given SourceFile#fileName starts with any of the paths.

That works if there are no symlinks. With symlinks one needs to use realpath on all of the typeRoots before comparing to fileName as that is already a realpath.
And even that doesn't cover cases where a subdirectory (like node_modules/@types/foo) or an individual file (node_modules/@types/foo/index.d.ts) is a symlink.

Related: https://github.com/fimbullinter/wotan/issues/387

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

Beginne mit dem Lesen von Program#isSourceFileFromExternalLibrary, ts.getEffectiveTypeRoots und der Verarbeitung von SourceFile#fileName. Verfolge, wie typeRoots und symbolisch verknüpfte Verzeichnisse oder Dateien dargestellt werden, und füge dann die vorgeschlagene Program#isSourceFileFromTypeRoots API mit Abdeckung für diese Fälle hinzu. Erledigt ist die Aufgabe, wenn Aufrufer Pfade nicht mehr selbst vergleichen müssen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
api, compilers
Issue-Typ
Feature
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

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