Using TypeScript with NativeScript
Using TypeScript with NativeScript is easy. From your terminal or command line, just start a new project with this command:
$ tns create my-app-name --template typescript
Adding TypeScript support to an existing NativeScript project is easy, too. Just run this command in your existing project root directory:
$tns install typescript
New to TypeScript?
Why use TypeScript with NativeScript?
TypeScript Is A First-Class Citizen In NativeScript
NativeScript is built with TypeScript. It’s not an afterthought, it’s how the code is written. That means there is 100% integration with all NativeScript APIs and even all native APIs when you use TypeScript.
TypeScript Means Intellisense
Combined with Visual Studio Code, TypeScript gives you powerful intellisense for your NativeScript projects. That means that you can see all available APIs, methods and properties right where you need them - inline with your code and not stuffed somewhere in the docs.
TypeScript Means Refactoring and productivity
Combined with Visual Studio Code, TypeScript gives you powerful refactoring capabilities. You can change a method/property signature in seconds without worrying that the old name will stay somewhere in the project. This is one of the reasons we decided to use for NativeScript - a large scale project.
NativeScript CLI configures your .tsconfig files and transpiles your .ts files for you without any extra build configuration required. Just build your project and NativeScript CLI will handle the rest.
TypeScript has amazing module support. Use CommonJS modules, or even the new ES6 module spec. It all “just works” with TypeScript and NativeScript. It’s easier than the web. Really.
Know Before You Go