Переглянути джерело

doc: add TypeScript setup documentation

David Peicho 5 роки тому
батько
коміт
449f44709d
2 змінених файлів з 49 додано та 0 видалено
  1. 1 0
      docs/list.js
  2. 48 0
      docs/manual/en/introduction/Typescript-setup.html

+ 1 - 0
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",

+ 48 - 0
docs/manual/en/introduction/Typescript-setup.html

@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html lang="en">
+	<head>
+		<meta charset="utf-8">
+		<base href="../../../" />
+		<script src="list.js"></script>
+		<script src="page.js"></script>
+		<link type="text/css" rel="stylesheet" href="page.css" />
+	</head>
+	<body>
+		<h1>[name]</h1>
+
+		<p>
+			three.js is a JavaScript-based library.
+		</p>
+			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.
+
+		<p>
+			A minimal configuration is required for the TypeScript compiler to
+			discover three.js types.<br>
+			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.
+		</p>
+
+		<code>
+		// Example of minimal `tsconfig.json` file
+		{
+			"compilerOptions": {
+				"target": "es6",
+				"moduleResolution": "node",
+			},
+			"include": [ "./src/**/*.ts" ],
+		}
+		</code>
+
+		<p>
+			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].
+		</p>
+
+		<p>
+			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.
+		</p>
+	</body>
+</html>