Including full error range in TSC output
See original GitHub issueFrom https://github.com/Microsoft/vscode/issues/70465
Repo
-
For the TS code with
strict
enabled:const obj = { prop: Date.now() ? 'str' : undefined } obj.prop.toLowerCase();
-
Run a tsc task in VS Code to see reported errors (make sure to close the ts file as well)
Problem
We currently only report the potential undefined access error on obj
in the line obj.prop.toLowerCase();
. The correct range should span obj.prop
.
The root cause of this is that VS Code’s problem matcher does not have the full range of the error from tsc, only the start line and column. Here’s the tsc output:
src/index.ts:7:1 - error TS2532: Object is possibly 'undefined'.
7 obj.prop.toLowerCase();
~~~~~~~~
With the current tsc output, there is also no way to extract the full range of the error.
Request
Somewhere in the line src/index.ts:7:1 - error TS2532: Object is possibly 'undefined'.
, add the end position as well so that tooling can properly highlight it. We would want to do this in a way that doesn’t detract from the error’s human readability. This needs some thought
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top GitHub Comments
Lots of times, JSON output is useful for connecting various build tools.
Right now it’s already possible to use Regex to parse out error messages:
However, this isn’t very portable, it’d be much nicer if you could specify a way to emit errors/warnings as JSON.
Other output can be printed to stderr, but stdout should be pipe-able as valid JSON.
@mjbvz How would you feel about a
--formatter json
command line option for providing diagnostics in a machine readable format from the command line tools? Or is that too far and away from the current problem matcher infrastructure to be useful?