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

オープン
#342 コメント 4 件 リアクション 3 件 担当者 0 名 GitHub で見る

関連するプルリクエストがすでにマージされています。

  • #343 @CodyJasonBennett による — マージ済み

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
停滞
技術スタック
three.js, typescript
領域
tooling

調査の方向性

まず、tsconfig.json の NodeNext 設定で src/Scene.tsx から報告された import を再現し、TSC を実行します。パッケージのエクスポートされた型と、NodeNext モジュール解決での動作を比較します。GLTF と GLTFLoader が ESNext/Node workaround を必要とせず、エクスポートされたメンバーとしてコンパイルできれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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.

主要言語
JavaScript
スター
863
フォーク
146
PR マージ指標
30日以内にマージされた PR はありません

環境構築

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pmndrs/three-stdlib のほかの issue

pmndrs/three-stdlib の issue をすべて見る

似ている issue

JavaScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。