microsoft / microsoft/TypeScript

`typesVersions` doesn't match behaviour of `exports`

Aperta
#56,957 0 commenti 4 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Awaiting More Feedback Suggestion
Lingua principale
Go
Stelle
111k
Fork
14.4k
Merge medio
1g 19h
PR unite (30g)
117

Descrizione

🔎 Search Terms
  • "typesVersions"
  • "exports"
🕗 Version & Regression Information
  • This relates to the work around Node.js exports (i.e. #53116).
  • This has never worked to my knowledge.
⏯ Playground Link

No response

💻 Code

package.json:

{
  "exports": {
    "./*": {
      "types": "./dist/types/*/*.d.ts",
      "import": "./dist/esm/*/*.js",
      "require": "./dist/cjs/*/*.js"
    }
  },
  "typesVersions": {
    "*": {
      "*": [
        "./dist/types/*/*.d.ts"
      ]
    }
  }
}
🙁 Actual behavior

These provided export paths work as expected in Node.js. For example, I can import from foo/dist/esm/bar/bar.js with:

import { bar } from 'foo/bar';

However, TypeScript is unable to resolve the double wildcard in typesVersions. I also see a validation error on the string ("./dist/types/*/*.d.ts") in VS Code.

🙂 Expected behavior

I'd expect that typesVersions behaves the same way that exports does.

Additional information about the issue

I realise that a quick solution to this would be to use index.js in each folder instead of a file with the same name as the folder, but wanted to report the different in behaviour here.

This may also technically be a feature request.

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.

Direzione di ricerca

Inizia con l'esempio di package.json e riproduci la risoluzione del doppio carattere jolly in typesVersions in base al pattern exports corrispondente. Quindi traccia la gestione di questi campi da parte di TypeScript durante la risoluzione dei moduli e il relativo percorso di validazione. Il lavoro è completo quando il pattern documentato viene accettato e risolto in modo coerente con il comportamento di exports.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
node.js, typescript
Ambito
compilers
Tipo di issue
Funzionalità
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.