Setting up native API type checking and generate AudioKit TypeScript definitions

The first thing we want to do is install tns-platform-declarations:

npm i tns-platform-declarations --save-dev

Now, we create a new file in the root of the project called references.d.ts with the following contents:

/// <reference path="./node_modules/tns-platform-declarations/ios.d.ts" />/// <reference path="./node_modules/tns-platform-declarations/android.d.ts" />

This provides us with full type checking and intellisense support for iOS and Android APIs.

We now want to generate typings for the AudioKit framework itself. We can execute this command to generate the typings for the included AudioKit.framework:

TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" ...

Get NativeScript for Angular Mobile Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.