nativescript-community / nativescript-vscode-extension

A Visual Studio Code Extension for NativeScript
https://www.nativescript.org/visual-studio-code
Apache License 2.0
82 stars 32 forks source link

Enable IntelliSense for iOS and Android native apis #103

Closed ignaciolarranaga closed 7 years ago

ignaciolarranaga commented 7 years ago

Right now when you are programming with the native APIs for iOS and Android there is no intellisense on the available classes or the methods they provide, it would be a nice to have.

For example if I type "PH" that suggest me that there is a class PHAsset on iOS Photo framework, and if I type "PHAsset." that shows me the methods it contains.

ignaciolarranaga commented 7 years ago

Just found it is already done.

Just for reference you have to add the dependency to tns-platform-declarations (npm install tns-platform-declarations --save-dev) ot your project and latter add the following to references.d.ts:

/// <reference path="node_modules/tns-platform-declarations/android.d.ts" />
/// <reference path="node_modules/tns-platform-declarations/ios.d.ts" />
ivanbuhov commented 7 years ago

Just to add that you can generate ios.d.ts and android.d.ts files manually. To generate ios.d.ts run the following command in your project directory:

TNS_TYPESCRIPT_DECLARATIONS_PATH="$(pwd)/typings" tns build ios [--for-device] [--release]

This will create typings folder under your project directory containing typescript definitions for iOS native APIs. Manually generating definitions for Android is in experimental state. You can find how to generate Android type definitions here.