diff --git a/javascript-manual/modules/ROOT/pages/install.adoc b/javascript-manual/modules/ROOT/pages/install.adoc index 3caa5c58..4697984c 100644 --- a/javascript-manual/modules/ROOT/pages/install.adoc +++ b/javascript-manual/modules/ROOT/pages/install.adoc @@ -25,7 +25,12 @@ You can install it with `npm i neo4j-driver-lite`. == Include the driver -Unless you are going to xref:browser-websockets.adoc[use the driver within a web browser], you use the JavaScript driver in a Node.js or TypeScript application. +Unless you are going to xref:browser-websockets.adoc[use the driver within a web browser], you use the driver in a Node.js or TypeScript application. + +[.tabbed-example] +===== +[.include-with-javascript] +====== To include the driver in your application, use `require`: [source, javascript] @@ -33,6 +38,39 @@ To include the driver in your application, use `require`: const neo4j = require('neo4j-driver') ---- +====== +[.include-with-typescript] +====== +To include the driver in your application, use `import`: + +[source, typescript] +---- +import neo4j, {Node} from 'neo4j-driver' +---- + +[IMPORTANT] +Import `Node` explicitly to avoid conflicts with the native `Node` type. The driver also doesn't declare a namespace, so you need to explicitly import any symbol you want to use as a type annotation. + +You can provide the list of libraries the driver needs via the `tsconfig.json` file (or exclude the interpreter check with `"skipLibCheck": true`), and then compile your code with `tsc` or run with an execution engine. + +.tsconfig.json sample file +[source, json] +---- +{ + "compilerOptions": { + "lib": ["ES6", "dom", "es2020.bigint", "esnext.asynciterable", "esnext.disposable"] + }, + "include": ["neo4j-main.ts"] +} +---- + +[TIP] +The minimum supported version is TypeScript 5.2. + + +====== +===== + include::{common-partial}/install.adoc[tag=get-an-instance]