Using TypeScript in JavaScript modules with the ServiceNow SDK
Use TypeScript when creating JavaScript modules with the ServiceNow SDK.
TypeScript uses static typing and type annotations to support developers catching errors earlier while writing code in Visual Studio Code.
For general information about using TypeScript, see the TypeScript Documentation on the typescriptlang.org website.
Use TypeScript in JavaScript modules
Use TypeScript in JavaScript modules by adding support for TypeScript in your application.
Before you begin
Install TypeScript version 4.8.4 or later. For installation instructions, see Download TypeScript on the typescriptlang.org website.
Role required: admin
About this task
Follow this procedure to update existing applications that weren't creating using the TypeScript template to use TypeScript in modules if you're using ServiceNow SDK version 2.2.9 or earlier. Beginning with the ServiceNow SDK version 3.0, applications support using TypeScript in JavaScript modules by default using default compiler options. To use a tsconfig.json file with custom options for
transpiling TypeScript into JavaScript during the build process, configure the tsconfigPath parameter in the now.config.json file. If you want to use a custom transpilation step before
building the application, configure the modulePaths parameter in the now.config.json file.
Procedure
Add type definitions for APIs
Get type-ahead support for APIs and scriptable objects outside of Glide APIs.
Before you begin
Role required: admin
About this task
Declare modules directly in the ServiceNow SDK application to stub access to the APIs for type-ahead support. These modules aren't packaged in the application package, but they can be tracked in a source control repository for the application and shared between developers.