Nativescript-angular: tns build is not compiling typescript to javascript

Created on 20 Feb 2018  Â·  9Comments  Â·  Source: NativeScript/nativescript-angular

I'm new to native script and learning as I go along. I'm trying to add a new page and I have created a directory/folder under the app root called views. Within this folder I generated a xml manually (intro-page.xml) and a supporting typescript file (intro-page.ts)

The intro-page.ts :

 import { EventData } from 'data/observable';
import { Page } from 'ui/page';
import { AuthViewModel } from '../../view-models/auth-view-model';
import * as appSettings from "application-settings";

let vm = new AuthViewModel();

export function navigatingTo(args: EventData) {
    let page = <Page>args.object;

    page.bindingContext = vm;
}

With this I was expecting that when I run "tns build android" typescript would be compiled to Javascript, but all I get in the intro-page.js:

//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW50cm8tcGFnZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImludHJvLXBhZ2UudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiIsInNvdXJjZXNDb250ZW50IjpbIiJdfQ==

needs more info

Most helpful comment

The transpilation of TS files to plain JS needs the TypeScript transpilator to be called. This is happening via the typescript hook. Now sometimes the hooks might be deleted and if the node_modules folders are not deleted as well the hooks folder won't be recreated! This means that if you are missing the hooks folder the transpilation will not be triggered.

Solution: remove node_modules folder and run npm i - this will recreate the hooks folder and the TypeScript files will be transpiled on the next build/run command.

All 9 comments

@pradt you are absolutely right - one of the first things the build command should do is run the TypeSxcript transpiler. However, when the newly created TS page is not transpiled it might be related to an error in the TypeScript part.

Try running only tsc and see if there is error output.

If the issue persists please provide a sample project that can reproduce this problem (and/or paste the versions of NativeScript used including runtimes e.g. tns-android and tns-ios, tns-core-modules and nativescript-angular)

Hi @NickIliev I am facing the same issue. you can check my code here . You can check main.ts and main.js file. i have tried everything like adding-removing android platform, npm install and tsc main.ts .

Hi, I'm having the same issue even though no errors in TypeScript files. Regular, build/run commands sometimes doesn't update the JavaScript files.

@tanmayparmar @cerireyhan did you manage to figure out why this is happening? I'm facing a similar issue, but only the xyz.service.ts files are not compiling to js. Component files are fine.

@suparnavg It was fixed for me after removing everything and adding again. (node modules, hooks, platforms)

I just removed everything and reinstalled it. Including typescript and
nativescript to the current version.

On Wed, Jun 13, 2018, 4:46 PM Çeri, notifications@github.com wrote:

@suparnavg https://github.com/suparnavg It was fixed for me after
removing everything and adding again. (node modules, hooks, platforms)

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/NativeScript/nativescript-angular/issues/1207#issuecomment-397080542,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AHAggNwwBc70ae1v5fztm4NRj4Xe7rSzks5t8XoagaJpZM4SL1QC
.

The transpilation of TS files to plain JS needs the TypeScript transpilator to be called. This is happening via the typescript hook. Now sometimes the hooks might be deleted and if the node_modules folders are not deleted as well the hooks folder won't be recreated! This means that if you are missing the hooks folder the transpilation will not be triggered.

Solution: remove node_modules folder and run npm i - this will recreate the hooks folder and the TypeScript files will be transpiled on the next build/run command.

hooks folder not recreated for me when I run npm i, and still I am facing this transpiled issue

up

Was this page helpful?
0 / 5 - 0 ratings

Related issues

manojdcoder picture manojdcoder  Â·  3Comments

Sulman633 picture Sulman633  Â·  3Comments

igorls picture igorls  Â·  3Comments

sunpasup picture sunpasup  Â·  3Comments

sarvagayatri picture sarvagayatri  Â·  3Comments