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

未关闭
#342 4 条评论 3 个 reaction 已指派 0 人 在 GitHub 查看

已经有一个关联 PR 被合并了。

  • #343 来自 @CodyJasonBennett —— 已合并

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
three.js, typescript
领域
tooling

调研方向

首先,使用 tsconfig.json 中的 NodeNext 设置重现从 src/Scene.tsx 报告的 import,并运行 TSC。将 package 导出的类型与 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 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

pmndrs/three-stdlib 的其他 Issue

查看 pmndrs/three-stdlib 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。