TypeScript设置([name])

three.js是一个基于JavaScript的库。但是,可以在TypeScript项目中使用它,因为该库公开了声明文件 [link:https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html Declaration Files](*d.ts* 文件)。

TypeScript编译器需要最少的配置即可发现three.js类型。
你将需要设置 [link:https://www.typescriptlang.org/docs/handbook/module-resolution.html moduleResolution] (模块解析)为 *node* 和 [link:https://www.typescriptlang.org/docs/handbook/compiler-options.html target] (目标) 为 *es6* 或更高版本。

// tsconfig.json文件最少配置例子 { "compilerOptions": { "target": "es6", "moduleResolution": "node", }, "include": [ "./src/**/*.ts" ], }

注意:到目前为止,如果不使用这两个选项,则无法使用three.js类型。

注意:某些声明可能不正确或缺失。为声明文件做贡献对社区真的很有帮助,使Three.js开发会更好更准确。