From 449f44709df82ea94dc90efce9e942805b1e45cf Mon Sep 17 00:00:00 2001 From: David Peicho Date: Wed, 8 Jan 2020 15:52:45 +0000 Subject: [PATCH 1/4] doc: add TypeScript setup documentation --- docs/list.js | 1 + .../en/introduction/Typescript-setup.html | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 docs/manual/en/introduction/Typescript-setup.html diff --git a/docs/list.js b/docs/list.js index b7b3633b757689..fa3bb62928f116 100644 --- a/docs/list.js +++ b/docs/list.js @@ -10,6 +10,7 @@ var list = { "Browser support": "manual/en/introduction/Browser-support", "WebGL compatibility check": "manual/en/introduction/WebGL-compatibility-check", "How to run things locally": "manual/en/introduction/How-to-run-things-locally", + "Typescript setup": "manual/en/introduction/Typescript-setup", "How to use WebGL 2": "manual/en/introduction/How-to-use-WebGL2", "Drawing lines": "manual/en/introduction/Drawing-lines", "Creating text": "manual/en/introduction/Creating-text", diff --git a/docs/manual/en/introduction/Typescript-setup.html b/docs/manual/en/introduction/Typescript-setup.html new file mode 100644 index 00000000000000..ce58b6ae3fbfab --- /dev/null +++ b/docs/manual/en/introduction/Typescript-setup.html @@ -0,0 +1,48 @@ + + + + + + + + + + +

[name]

+ +

+ three.js is a JavaScript-based library. +

+ However, it's possible to use three.js in a TypeScript project, as the library + exposes [link:https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html TypeScript declaration files] (*.d.ts* files) making it usable in TypeScript projects. + +

+ A minimal configuration is required for the TypeScript compiler to + discover three.js types.
+ You will need to set the [link:https://www.typescriptlang.org/docs/handbook/module-resolution.html moduleResolution] + option to *node*, and the [link:https://www.typescriptlang.org/docs/handbook/compiler-options.html target] to *es6* or newer. +

+ + + // Example of minimal `tsconfig.json` file + { + "compilerOptions": { + "target": "es6", + "moduleResolution": "node", + }, + "include": [ "./src/**/*.ts" ], + } + + +

+ As of today, it's not yet possible to three.js in a TypeScript project + without using the [link:https://www.typescriptlang.org/docs/handbook/module-resolution.html node module resolution algorithm]. +

+ +

+ Note: It happens that some declarations are incorrect and/or missing. + Contributing to Types Declaration Files is really helpful for the community, making three.js + typings better and more accurate. +

+ + From be9324d577c2b926ff419a7b6c2b199a40bf0990 Mon Sep 17 00:00:00 2001 From: David Peicho Date: Wed, 8 Jan 2020 17:33:09 +0000 Subject: [PATCH 2/4] doc: TypeScript: fix typo --- docs/manual/en/introduction/Typescript-setup.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/manual/en/introduction/Typescript-setup.html b/docs/manual/en/introduction/Typescript-setup.html index ce58b6ae3fbfab..b5454de3371937 100644 --- a/docs/manual/en/introduction/Typescript-setup.html +++ b/docs/manual/en/introduction/Typescript-setup.html @@ -11,10 +11,9 @@

[name]

- three.js is a JavaScript-based library. + three.js is a JavaScript-based library. However, it's possible to use three.js in a TypeScript project, as the library + exposes [link:https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html TypeScript declaration files] (*.d.ts* files).

- However, it's possible to use three.js in a TypeScript project, as the library - exposes [link:https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html TypeScript declaration files] (*.d.ts* files) making it usable in TypeScript projects.

A minimal configuration is required for the TypeScript compiler to @@ -35,8 +34,7 @@

[name]

- As of today, it's not yet possible to three.js in a TypeScript project - without using the [link:https://www.typescriptlang.org/docs/handbook/module-resolution.html node module resolution algorithm]. + Note: As of today, it's not yet possible to use three.js typings without using those two options.

From 8b8c354c96429fe809f1297dc72b78df160bffa6 Mon Sep 17 00:00:00 2001 From: David Peicho Date: Wed, 8 Jan 2020 17:41:38 +0000 Subject: [PATCH 3/4] doc: TypeScript: rephrase & fix typo --- docs/manual/en/introduction/Typescript-setup.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/manual/en/introduction/Typescript-setup.html b/docs/manual/en/introduction/Typescript-setup.html index b5454de3371937..863ce5cf0a43d1 100644 --- a/docs/manual/en/introduction/Typescript-setup.html +++ b/docs/manual/en/introduction/Typescript-setup.html @@ -11,15 +11,15 @@

[name]

- three.js is a JavaScript-based library. However, it's possible to use three.js in a TypeScript project, as the library - exposes [link:https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html TypeScript declaration files] (*.d.ts* files). + three.js is a JavaScript-based library. However, it's possible to use it in a TypeScript project, as the library + exposes [link:https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html Declaration Files] (*d.ts* files).

A minimal configuration is required for the TypeScript compiler to discover three.js types.
You will need to set the [link:https://www.typescriptlang.org/docs/handbook/module-resolution.html moduleResolution] - option to *node*, and the [link:https://www.typescriptlang.org/docs/handbook/compiler-options.html target] to *es6* or newer. + option to *node*, and the [link:https://www.typescriptlang.org/docs/handbook/compiler-options.html target] option to *es6* or newer.

@@ -39,7 +39,7 @@

[name]

Note: It happens that some declarations are incorrect and/or missing. - Contributing to Types Declaration Files is really helpful for the community, making three.js + Contributing to Declaration Files is really helpful for the community, making three.js typings better and more accurate.

From 5a684e05a93167518a2a604812d50a2162c95ed6 Mon Sep 17 00:00:00 2001 From: David Peicho Date: Wed, 8 Jan 2020 17:43:55 +0000 Subject: [PATCH 4/4] doc: TypeScript: add placeholder for chinese translation --- docs/list.js | 1 + .../zh/introduction/Typescript-setup.html | 46 +++++++++++++++++++ 2 files changed, 47 insertions(+) create mode 100644 docs/manual/zh/introduction/Typescript-setup.html diff --git a/docs/list.js b/docs/list.js index fa3bb62928f116..311af6d959027e 100644 --- a/docs/list.js +++ b/docs/list.js @@ -460,6 +460,7 @@ var list = { "浏览器支持": "manual/zh/introduction/Browser-support", "WebGL兼容性检查": "manual/zh/introduction/WebGL-compatibility-check", "如何在本地运行Three.js": "manual/zh/introduction/How-to-run-things-locally", + "Typescript setup": "manual/zh/introduction/Typescript-setup", "如何使用WebGL 2": "manual/zh/introduction/How-to-use-WebGL2", "画线": "manual/zh/introduction/Drawing-lines", "创建文字": "manual/zh/introduction/Creating-text", diff --git a/docs/manual/zh/introduction/Typescript-setup.html b/docs/manual/zh/introduction/Typescript-setup.html new file mode 100644 index 00000000000000..863ce5cf0a43d1 --- /dev/null +++ b/docs/manual/zh/introduction/Typescript-setup.html @@ -0,0 +1,46 @@ + + + + + + + + + + +

[name]

+ +

+ three.js is a JavaScript-based library. However, it's possible to use it in a TypeScript project, as the library + exposes [link:https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html Declaration Files] (*d.ts* files). +

+ +

+ A minimal configuration is required for the TypeScript compiler to + discover three.js types.
+ You will need to set the [link:https://www.typescriptlang.org/docs/handbook/module-resolution.html moduleResolution] + option to *node*, and the [link:https://www.typescriptlang.org/docs/handbook/compiler-options.html target] option to *es6* or newer. +

+ + + // Example of minimal `tsconfig.json` file + { + "compilerOptions": { + "target": "es6", + "moduleResolution": "node", + }, + "include": [ "./src/**/*.ts" ], + } + + +

+ Note: As of today, it's not yet possible to use three.js typings without using those two options. +

+ +

+ Note: It happens that some declarations are incorrect and/or missing. + Contributing to Declaration Files is really helpful for the community, making three.js + typings better and more accurate. +

+ +