KeyLines and TypeScript

Getting Started

Introduction

KeyLines supports the use of TypeScript. You can write your application in TypeScript to make use of features such as intellisense, compile-time type checking and context-sensitive API documentation.

TypeScript is a strongly typed, open source superset of JavaScript that is compiled to simple JavaScript and runs on any browser. It features type annotations that let you record contracts of functions and variables in a lightweight way. It lets you use existing JavaScript code, import other JavaScript libraries, and call TypeScript code from JavaScript.

We regularly test our definition files against the latest available TypeScript version.

Using TypeScript with KeyLines

When using JavaScript libraries (such as KeyLines) with TypeScript, it’s useful to have the type definitions for each library. KeyLines comes with detailed type definitions that are updated every time there's a change to the KeyLines API. Including these definitions in your project makes coding in TypeScript much easier.

The easiest way to include the TypeScript files is by installing KeyLines as a package. This makes the TypeScript definitions available in your code automatically.

For examples of how to import KeyLines as a package using the npm package manager, see the 'Using KeyLines...' tutorials in the Installing KeyLines section of our documentation.

Using KeyLines type definitions

You can use KeyLines normally and TypeScript will provide type checking of your application code using the KeyLines type definitions.

You can also import types from the KeyLines package to help you develop more complex TypeScript applications. For example, to import KeyLines along with the Chart and TimeBar types, you can use the following import pattern:

import KeyLines, { Chart, TimeBar } from 'keylines/esm';

If you're using many types, it might be more convenient to access them by a namespace. For example:

import KeyLines, * as kl from 'keylines/esm';

TypeScript demos

Although most of our demos are not written in TypeScript, we have used TypeScript definitions to write source code for the Angular Integration demo.

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.