Visual Studio 2015 and typescript errors don't appear
Hello,
First of all. Awesome stuff here. However, when I have errors in my typescript files, visual studio 2015 will continue to build and NOT show me these errors.
Am I doing something wrong? How can I get Visual studio to show me typescript errors?
When you press 'build' in VS, you're executing the build steps defined by your project file (.csproj/project.json). The project templates on this repo are set up so that the project file compiles your C# source code into .NET assemblies in the usual way, but they are not set up to build your TypeScript (into JavaScript). These templates expect you to invoke Webpack whenever you want to build your TypeScript, which you can do in various ways:
- In development mode, just running your project causes TypeScript to be (re)built whenever you change your source files. That's the Webpack dev middleware feature. Most of the time, this means you don't need to take any manual steps. If there are errors, you should see them highlighted in VS with red underlines, and would also see the error details as an error in your browser or its console if you reloaded the page.
- Or, in a command prompt, you can execute
webpack. - Or, you could use something like Webpack task runner to invoke Webpack from inside VS via a button/menu click
- Or, if you really want, you could modify your
.csproj/project.jsonfile so that it executes Webpack (and hence builds TypeScript, collecting any errors) whenever you build your .NET project
The reason we don't have it set up as in option 4 by default is that it would substantially increase build times (TypeScript takes probably 5 seconds or more for a cold-start compile if it has to parse a big library like Angular 2), and because the Webpack dev middleware setup largely eliminates the need for this and is far faster (usually doing incremental recompiles in under 1 second).
Hope that makes sense!
How can I get Visual studio to show me typescript errors?
As mentioned above, you should be seeing the red squiggly line highlights for TypeScript errors inside VS. If you don't see them, that suggests you don't have the TypeScript tools for Visual Studio installed correctly. But you won't get TypeScript compiler errors in the list of build errors unless you modify your project as in option 4 above, and then put up with substantial increases in build times.
Thanks for the detailed feedback. It for sure helps clear up my understanding. Would there be any chance of the build process to collect the errors from webpack that was already compiled?
This template is awesome. Keep up the great work.