Typescript compilation stops on js errors?


#1

Hi guys,

I have a huge problem. When I run the ionic serve command, the app.bundle.js file is not created if there is a javascript error somewhere in the code. It lists the error and that’s it. Shouldn’t it try to compile despite the errors? I believe that the Typescript compiler should do this (unless the “noEmitOnError” flag is set to true in tsconfig.ts), so I guess the Ionic build process somehow forces this flag to true and overrides tsconfig?

I’m converting an old (huge) Ionic 2 project (back when awesome-typescript-loader was used for compilation, I believe) to the new beta.11, and before, it ignored all the errors and everything worked just fine.

TL;DR: How can we force Ionic Serve to build the resulting js file even if there are js errors in the code?

I’m really hoping for some input here since I’m really stuck!
Thanks!


#2

Maybe not what you want to hear, but I think it’s good that the compiler doesn’t produce any results if the compilation failed.

Per definition it’s the way compilators works to ensure that the results/compilated code works all together. Otherwise you will always have to check manually your logs to ensure that you didn’t forgot any errors.

With these remarks done, what is your errors? Could you post the logs here?

Not sure I could help but could have a look and try.


#3

I hear what you are saying but I think this should really be up to the developer. And like I said, the typescript compiler even ignores these errors by default. I tried compiling a clean Angular 2 project with errors in it, and it compiled despite of them. Why would Ionic behave any differently?

The errors are basic ones (and do in no way actually make compilation impossible) and easy to fix, but there are tons of them. For example, sometimes, objects are added to "this"at runtime so the compiler doesn’t know about them. It throws an error like this: Property 'i18n' does not exist on type 'VerifyAccount'. I know of course that I can define them, but it should compile despite these errors. It did before.

I really hope that there is a way around this :frowning:


#4

I guess we both have our point of view, maybe coming from different past coding languages experiences.

Anyway, won’t argue that much more, just wanted to say that I just ran a refactoring where I changed some of my model types (like from array of string to string and vice versa) and I’m actually pretty happy I couldn’t start my app till I had fix everything…just for the record :wink:


#5

I’ve managed to get it to build (thanks to some help from the ionic team) despite the errors, and I managed to get the project up and running again.

Also, I would say that the client/employer situation, time criticality of the project and budgeting concerns play a lot larger role in this than “past coding languages experiences”, but thanks for the condescending addition to the record :slight_smile:


#7

You can always do:

declare var MyJavascriptLibrary;

I don’t recommend doing this normally, but it’s a viable solution when you don’t have any typings.


#9

Why can’t you fix the program so that it compiles without error instead?


#11

OK. I’ll try to make sure never to respond to any of your posts again.