microsoft / microsoft/TypeScript

Module resolution using nodenext and a wildcard in package.json exports

Aperta
#55,021 7 commenti 26 reazioni 1 assegnatario Vedi su GitHub

@weswigham ci sta già lavorando.

Dal 24/7/2023.

Needs Investigation Rescheduled
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

Bug Report

🔎 Search Terms

Nodenext wildcard, type cannot be named

🕗 Version & Regression Information

The bug only appears when using nodenext for module resolution

⏯ Playground Link

Cloneable repo: https://github.com/geoffreytools/effect-test-tsc

💻 Code
import { TaggedClass } from '@effect/data/Data';
// import '@effect/data/Equal';

export class Foo extends TaggedClass('Foo')<{}> {}
🙁 Actual behavior
The inferred type of 'Foo' cannot be named without a reference to '../node_modules/@effect/data/Equal'. This is likely not portable. A type annotation is necessary.
🙂 Expected behavior

To compile correctly, without using nodenext it works fine and the same issue doesn't apply to other transitive imports such as Hash that are identically exported. All goes away the very moment there is either an explicit import of Equal or when adding to the library package.json the following:

{
  "exports": {
    "./Equal": {
      "import": {
        "types": "./Equal.d.ts",
        "default": "./mjs/Equal.mjs"
      }
    }
  }
}

Note that the library uses a wildcard ./* as each import map to a file and this is perfectly resolvable by node

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.