Norbert Norbertson Norbert Norbertson - 6 months ago 63
AngularJS Question

typescript compile on save breaks AngularJS in Visual Studio 2017

I have a Visual Studio Community 2017 (15.2) project with AngularJS 1.6.5 and a NancyFX server.

Code here:

This is a playground for me to learn and test features I'd like to use on a real project.

All the AngularJS stuff is in Typescript files and my tsconfig.json tells the compiler to compile it all into a single JS file


When I build and run the project everything works as expected and there are no issues. However, if I edit a .ts file while the app is running it breaks with this error:

angular.min.js:7 Uncaught Error: [$injector:nomod]$injector/nomod?p0=mySPA

The compile on save seems to work fine since the
is rebuilt on save. But why do I get the Angular error only on compile on save?

Am I doing something wrong in my AngularJS code or is this a Typescript/Visual Studio thing?

If I build and publish the project it runs fine under IIS and I can't break it.

Answer Source

I noticed that outside of VS if I compiled the typescript using tsc then the order of files in my tsconfig.json was honored so I assumed a bug in the VS typescript tools.

So I went to and noticed a new version had just been released (2.4.1).

Installing this fixed the issue for me. The ts compiler now reads the files in the specified order and bundles them correctly.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download