1

I'm writing an app in NativeScript, using Typescript and Angular.

Something weird happened - suddenly the code I write in main.ts file has no effect on the app. I checked to see - the corresponding main.js file did npt change after running 'tns build ios/android' and 'tns run ios/android'.

So I want to ask - since when writing in NativeScript - every .ts file gets "translated" to .js file - is it safe to delete the corresponding main.js file so that a new updated main.js file is created?

Thanks.

Lorraine R.
  • 1,545
  • 1
  • 14
  • 39
  • Also, please try to answer why my .ts files became ineffective? Only code changed in .js files really changes the app. Thanks. – Lorraine R. Sep 25 '18 at 03:13
  • 1
    Hi Mickelson Morely, if you delete the JavaScript file(in your case `main.js`), the file will be generated again when the TypeScript files are transpiled to JavaScript. Regarding the issue you are facing, it seems like a local problem with the TypeScript compiler. If you are having a similar issue again, try deleting `node_modules`, `hook` and `platforms` folders and build the project again via `tns run ios/android` – Nikolay Tsonev Sep 26 '18 at 05:24
  • Yes I did that, but it didn't help. The solution I had to do was this - doing a "hard-reset" for everything. – Lorraine R. Sep 27 '18 at 21:07

1 Answers1

0

As Nikolay Tsonev mentioned in his comment, there was a problem in transpiling TypeScript files to Javascript in this project, while in other projects - transpilling worked fine

So the way I solved this was to do a "hard-reset" like this:

  1. Shutdown all terminal windows and threads.
    1. Deleting node_modules, hook and platforms folders.
    2. Reset xCode simulator by choosing "Hardware -> Erase All Content and Settings" (more on this here: How do I reset the Simulator in Xcode 9)
    3. Close AVD emulator and wipe its data.
    4. Reset the mac (I was working on the same session without reset for almost two months).
    5. Install a fresh project from the beginning, using:
tns create ns-audio11 --template tns-template-hello-world-ts

cd ns-audio11

tns platform add android

tns platform add iOS

tns run android

tns run ios

code .

And now Typescript code was effective again!

Lorraine R.
  • 1,545
  • 1
  • 14
  • 39