This page also assumes you have a npm project already, if you do not, you may need to run
In a TypeScript environment, GoJS typings will appear automatically if you have the
gojs npm package installed.
These typings will offer auto-completion, inline documentation, and value error checking.
For example when defining a shape, it will auto-complete
strokeWidth and display documentation:
strokeWidth does not exist on Node, it will point out an error:
provided you have TypeScript installed.
The easiest way to use typings is to install the GoJS npm package,
even if you are referencing the
go.js library from somewhere else, such as a CDN.
And of course you must also install TypeScript in your project, or globally.
npm i typescript --save-dev npm i gojs --save-dev
And you must create a TypeScript configuration file:
npx tsc --init
tsconfig.jsonfile, you will have to enable the
To make sure the symbol is accessible, you must add this triple-slash directive to the top of your
This allows type checking in JS files without defining "go".
/// <reference path="./node_modules/gojs/release/go.d.ts" />
TypeScript will identify this as a valid export of the "go" global object.
you can access the
go object through import and TypeScript typings will work:
import * as go from 'gojs';