Skip to content

Sample JavaScript Version #10

Closed
Closed

Description

@pollyolly

I tried converting it using typescriptlang.org but it seems not to work.

Activity

  1. pollyolly commented on Oct 6, 2019

    @pollyolly
    Author

    Hello I finally make this work. Here's what I do.

    install the required dependencies to run a typscript.
    install typescript

    and if you dont have tns-platform-declaration install it inside the nativescript node_modules npm install tns-platform-declaration.

    now in your application root folder create a filename references.d.ts

    copy paste the code below inside the references.d.ts

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

    now copy the tsconfig.json of this repository in your root folder outside of ./app folder.

    also the references.d.ts.

    Then to call the typescript code inside your javascript mine inside the app.js.

    const JobServiceIOS = require('./common/JobService.ios.ts');
    application.ios.delegate = JobServiceIOS.CustomAppDelegate;
    

    and inside the typescript code of the custom-app-delegate.ts add this line.

    const instance = new CustomAppDelegate();
    export const JobServiceIOS = instance;
    

    Note:

    • If you encounter an error saying Error module typescript. You need to update your package.json and add "typescript": "~version of typscript". Also make sure you installed typescript globally. npm i -g typescript

    Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions