"no exported member" errors when using NodeNext module/moduleResolution in TypeScript

Aperta
#342 4 commenti 3 reazioni 0 assegnatari Vedi su GitHub

Una pull request collegata è già stata integrata.

  • #343 di @CodyJasonBennett — integrata

Valutazione

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

Direzione di ricerca

Inizia riproducendo l’import segnalato da src/Scene.tsx con le impostazioni NodeNext in tsconfig.json ed esegui TSC. Confronta i tipi esportati dal pacchetto con il comportamento in base alla risoluzione dei moduli NodeNext. Il lavoro è completato quando GLTF e GLTFLoader vengono compilati come membri esportati senza richiedere il workaround ESNext/Node.

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

Descrizione

bug released
  • three version: n/a
  • @types/three version: n/a
  • three-stdlib version: 2.29.4
Problem description:

I ran into this bug and it took a while to figure out. It turns out that this library (as well as threes-stdlib) are not compatible with "NodeNext" module/moduleResolution, e.g. if you tsconfig.json looks like this:

    "module": "NodeNext",
    "moduleResolution": "NodeNext",

And you try to use this library like this:

Code:

import { GLTF, GLTFLoader } from 'three-stdlib'

You will get compile errors via TSC like this:

src/Scene.tsx:17:16 - error TS2305: Module '"three-stdlib"' has no exported member 'GLTFLoader'.

You can work around the bug by switching your tsconfig.json to something like this instead:

    "module": "ESNext",
    "moduleResolution": "Node",
Relevant code:

Included in the above description.

Suggested solution:

I suspect there is some way to fix this? But I do not yet know. One clue is that @react-three/fiber and @react-three.drei work properly with these tsconfig.json settings.

Lingua principale
JavaScript
Stelle
863
Fork
146
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

  • Nessun Dockerfile né file Docker Compose
  • Ha un modello di pull request
  • Nessuna 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.

Altre issue di pmndrs/three-stdlib

Tutte le issue di pmndrs/three-stdlib

Issue simili

Altre issue su JavaScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.