microsoft / microsoft/TypeScript
Including full error range in TSC output
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
From https://github.com/Microsoft/vscode/issues/70465
Repo
-
For the TS code with
strictenabled: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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the provided strict TypeScript example and inspect the tsc diagnostic output for TS2532. Determine how to include the diagnostic end position without reducing human readability; done means tooling can extract the full range and the existing error remains understandable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100