microsoft / microsoft/TypeScript

TS does not support resolving paths with colons

Offen
#57,529 8 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bug Domain: Module Resolution Help Wanted
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
1 T. 19 Std.
Gemergte PRs (30 T.)
117

Beschreibung

🔎 Search Terms

https://github.com/microsoft/TypeScript/issues?q=is%3Aissue+colon+exports+is%3Aclosed

colon, exports

🕗 Version & Regression Information
  • This is the behavior in every version I tried
⏯ Playground Link

https://stackblitz.com/edit/stackblitz-starters-d2rfdx?description=Starter%20project%20for%20Node.js,%20a%20JavaScript%20runtime%20built%20on%20Chrome%27s%20V8%20JavaScript%20engine&file=package.json&title=node.new%20Starter

💻 Code

Consumer module:

import a from 'my-library';
import b from 'my-library/foo';
import c from 'my-library/foo:virtual';
import d from 'my-library/bar';
import e from 'my-library/colon:here';

console.log({ a, b, c, d, e });

package.json for my-library:

{
  "name": "my-library",
  "version": "0.0.1",
  "type": "module",
  "exports": {
    ".": {
      "types": "./foo.d.ts",
      "default": "./foo.js"
    },
    "./foo": {
      "types": "./foo.d.ts",
      "import": "./foo.js"
    },
    "./foo:virtual": {
      "types": "./foo.d.ts",
      "default": "./foo.js"
    },
    "./*": {
      "types": "./*.d.ts",
      "default": "./*.js"
    }
  },
  "scripts": {
    "lint": "attw --pack; pnpm publint"
  },
  "dependencies": {
    "@arethetypeswrong/cli": "^0.14.1",
    "publint": "^0.2.7"
  }
}

every imported module is supposed to resolve, and then print:

{ a: 2, b: 2, c: 2, d: 2, e: 'two' }

(pnpm start in the consumer package in the repro link shows this)

🙁 Actual behavior

Errors, cannot find module
image

🙂 Expected behavior

align with JS, resolve the module

Additional information about the issue

No response

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 StackBlitz-Repro und dem pnpm start des Consumer-Pakets und untersuche dann die gezeigten package.json-Exports-Einträge, die Doppelpunkte enthalten. Verfolge das Verhalten der TypeScript-Modulauflösung für diese Package-Subpaths und vergleiche es mit dem Ergebnis der JavaScript-Laufzeit. Erledigt ist die Aufgabe, wenn alle fünf Imports aufgelöst werden und die erwartete Ausgabe erzeugen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

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

Neue Issues direkt in Ihr Postfach

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