microsoft / microsoft/TypeScript

@types dependency resolution can reference incorrect version

Aperta
#59,173 1 commento 0 reazioni 1 assegnatario Vedi su GitHub

@sheetalkamat ci sta già lavorando.

Dal 26/7/2024.

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

Descrizione

🔎 Search Terms

dependency dependencies types tree version

🕗 Version & Regression Information

This is the behavior in every version I tried, and I reviewed the FAQ for entries about Common "Bugs" That Aren't Bugs

⏯ Playground Link

https://stackblitz.com/edit/stackblitz-starters-qvn2zc

💻 Code

Consider the following dependency tree:

- @types/
  - send
    - mime@^1

- mime@^4 # This version of mime comes packaged with it's own types

- send
  - mime@^1

And therefore the following directory structure:

node_modules/
  @types/
    send/
    mime/
  mime/
  send/
    node_modules/
      mime/
🙁 Actual behavior

When the @types/send package attempts to reference mime it ends up importing mime(@^4) and not @types/mime, even though it's package.json dependency specifically references that version.

Therefore when you run npx tsc in this package it cannot compile.

🙂 Expected behavior

When @types/send was to reference mime, I'd expect it to reference @types/mime.

Additional information about the issue

I only stumbled across this problem as the mime@^4 package is ESM while @types/send was hoping to import a CommonJS version of mime@^1

Screenshot 2024-07-08 at 10 43 45

I have made a tiny stackblitz project here: https://stackblitz.com/edit/stackblitz-starters-qvn2zc
And I have also added the same sources to a git repo: https://github.com/johngeorgewright/typescript-dep-error

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.