TypeScript Strict in Visual Studio Code Problems Panel
typescript, visual-studio-code
Solution
You need to setup a `tsconfig.json` file to tell VScode what your project looks like and what compiler options to use for error reporting. Just create a `tsconfig.json` at the root of your workspace with the content:
{
"compilerOptions": {
"strict": true
},
"exclude": [ "node_modules" ]
}
You would then compile your project using `tsc -p tsconfig.json` instead of passing the the `--strict` flag
Problem
I've figured out that I can compile my TypeScript using the `--strict` flag which enforces stronger type checking etc. I often compile my TypeScript from within Visual Studio Code by using a task that gives me the output of the compile in the Output panel so I can see compilation errors, etc (see screenshot below). However, even though Visual Studio Code seems to perform "pre-compilation" of the TypeScript and reports basic syntax errors (etc) in the Problems panel, the strict results never appear there. (Note that my main project is C# ASP.NET with a TypeScript component). Is there a way to configure Visual Studio Code to pre-compile TypeScript using the `--strict` option so the errors appear in the Problems panel?