Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including tns-platform-declarations with all npm packages installed. Try it out:

var tnsPlatformDeclarations = require("tns-platform-declarations")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

tns-platform-declarations v5.4.3

Platform-specific TypeScript declarations for NativeScript for accessing native objects

This plugin contains type information about the native platforms as exposed by the NativeScript framework.

Offically supported entry points:

  • android.d.ts - For android SDK and runtime types.
  • ios.d.ts - For iOS SDK and runtime types.

Using the declarations may conflict with DOM typings, consider using TypeScript 2.x.x and the following settings in your tsconfig.json:

{
    "compilerOptions": {
        "module": "commonjs",
        "target": "es5",
        "experimentalDecorators": true,
        "lib": [
            "es6",
            "dom"
        ]
    }
}

Create reference.d.tsand add the following content:

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

By default the android.d.ts file contains the typings for android API level 17. If your application has a higher minimum API level you can reference that level instead:

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

d.ts files require a lot of memory and CPU. Consider adding skipLibCheck option to tsconfig file.

Generate android .d.ts files

  • To generate android dependencies use android-dts-generator with the appropriate android version and android support jars
  • To regenerate android-*.d.ts file use the android-dts-generator passing the corresponding android jar (described here)
  • More details for using the android-dts-generator can be found in this article.

Generate ios .d.ts files

The .d.ts files for iOS are generated using iOS Runtime's metadata generator. You can use the typings-gen.sh script like this:

./typings-gen.sh rc [<path-to-medatadata-generator-binary>]

Where rc can be an NPM tag/version of tns-ios that will be used for generating the typings. If the metadata generator to be used has not been released in NPM, you can optionally specify its path as a 2nd argument.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free