25 Feb 2019

TypeScript Definitions for Forge Viewer and Node.js Client SDK Now Available!

As the front-end domain continues to embrace the emerging, next-generation technologies, we have observed a surge in demand for TypeScript definitions (formerly known as typings) for our Forge libraries as our community takes to a typed approach to their JavaScript stacks. That demand has never gone unnoticed - today we present you the official release of TypeScript definitions for our Forge Viewer and Node.js client SDK.

Prerequisites

 

  • TypeScript 2.x or later (for 1.x we recommend to upgrade your project - see here for details.
  • NPM

Usage

To use these definitions in your TypeScript project, install and import them separately as stand-alone dependencies as appropriate to your requirements.

Forge Viewer

Install @type/forge-viewer

npm install --save-dev @types/three @types/forge-viewer #three.js types are required

Reference the definitions in your TypeScript configurations:

// tsconfig.json or your framework-specific config file such as tsconfig.app.json
{
    "types": ["forge-viewer"]
}

 

Forge API Node.js Client SDK

Install @types/forge-apis

npm install --save-dev @types/forge-apis

 

Code Sample

We've updated our Viewer TypeScript sample to adopt these definitions. This should be a great start for anyone looking to dive into TypeScript with Forge Viewer as well.

Feedback

Feel free to chip in with suggestions, bug reports and feature requests by creating an issue or pull request to the following repositories:
- https://github.com/dukedhx/DefinitelyTyped/ (source files can be found here (Forge Viewer) and here (Forge API Node.js Client SDK)
- https://github.com/Autodesk-Forge/viewer-nodejs-typeview.sample

Alternatively you can follow the official guide here to report an issue - be sure to tag me (Bryan Huang) in your request so we can be notified and attend to it.

Credits

Our special thanks go to Alan Smith from NBS, an Autodesk Solution Associate and Forge ISV partner, for contributing profoundly to our definitions for Forge Viewer. Thank you so much Alan!

Related Article