microsoft / microsoft/TypeScript

Bug: Incorrect module resolution for "valid" ES2015 specifiers with hashes and/or search parameters

Offen
#22,689 1 Kommentar 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Awaiting More Feedback Domain: ES Modules Suggestion
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.4k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

TypeScript Version: 2.8.0-dev.20180315

Search Terms: moduleResolution "module path" hash

Code

import { x as x1 } from './x.m.js';  // Typed correctly on hover
import { x as x2 } from './x.m.js#esm' // Typed as "import x…" on hover

Expected behavior:

Since module specifiers are now standardized, whereby if given an absolute specifier (or a relative specifier and the absolute referrer) should always result in a validly constructed new URL(specifier, referrer) it is expected that when a specifier includes suffix aspects like hash and search, that those aspects would be excluded from the pathname that is being resolved.

The implications of hash and search in runtime is beyond the scope of TypeScript and should remain so unless somehow the environment is customized to behave different (plugins maybe). However, if at all relevant, the specs have stated that at runtime each unique "resolved" URL (including hash and search) evaluates to a single unique instance of the respective module. It is not expected that TypeScript would need to determine if and when a module is a specific unique instance. It is however expected that when suffix aspects are included in the specifier that TypeScript would still resolve it's types identically as it does for the pathname sans hash and search.

Sorry for the long text!

Actual behavior:

TypeScript does not resolve pathnames with hash or search parameters.

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

Reproduziere das Problem mit den beiden gezeigten Import-Anweisungen und vergleiche die Auflösung von './x.m.js' mit './x.m.js#esm' sowie den erwarteten Pfadnamen ohne Hash oder Search. Beginne damit, die Behandlung von Import-Spezifizierern bei der Modulauflösung von TypeScript nachzuverfolgen; fertig ist die Arbeit, wenn beide Spezifizierer zu denselben Typen aufgelöst werden und dabei alle laufzeitspezifischen Suffix-Semantiken außerhalb von TypeScript erhalten bleiben.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
typescript
Bereich
compilers
Issue-Typ
Bug
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.