Advanced Concepts
Generating TypeScript types
Generate types for iOS
ns typings iosThis will generate the following folder structure typings/ios/arm64
Generate types for Android
For Android run:
ns typings android --jar <path to a jar>
# or
ns typings android --aar <path to an aar>You can also generate typings for an Android package (Maven):
ns typings android <package-name>For instance:
ns typings android "com.google.android.gms:play-services-tasks"Generate types for Windows
Experimental
The Windows platform is experimental. See Developing for Windows.
On a Windows machine, run:
ns typings windowsThis generates typings for the Windows.* WinRT APIs into typings/windows/, one .d.ts file per namespace group. If the project hasn't been prepared for Windows yet, the CLI runs ns prepare windows first to get the typings generator from @nativescript/windows.
The following options control what is generated:
| Option | Description |
|---|---|
--root <namespace> | The root namespace to generate typings for, for example Microsoft for WinUI 3. Defaults to Windows. |
--roots <ns1,ns2,...> | A comma separated list of namespaces, for example Windows.Foundation,Windows.Storage. |
--input <path> | Generate typings for a .winmd file (WinRT component) or a .dll/.csproj (.NET library). |
--lib <path> | An additional .winmd, .dll, .nupkg or folder used to resolve referenced types. Can be repeated. |
--libs <a,b,...> | A comma separated list of --lib paths. |
For instance, to generate typings for your own C++/WinRT component:
ns typings windows --input App_Resources/Windows/libs/x64/MyCompany.Native.winmdCustom code
- Reference the generated types in references.d.ts
- You can now code against the platform native APIs (strongly typed). For various examples on how to interact with native APIs in JavaScript/TypeScript, visit the Subclassing, iOS Marshalling, Android Marshalling and Windows Marshalling pages.
Additional Resources
- Android d.ts Generator, for advanced types generation for Android
- Previous
- Adding Windows Code


