Skip to content

Add error locations to TSError #1705

Closed
@paulbrimicombe

Description

@paulbrimicombe

Desired Behavior

When a TSError is thrown it would be very helpful to be able to programatically extract the location of the compilation error(s) in the source code.

Is this request related to a problem?

  • I maintain a library that compiles TypeScript snippets in markdown files: https://github.com/bbc/typescript-docs-verifier
  • I use ts-node to do the compilation because it provides a really simple and easy-to-use API (thanks! 🎉)
  • If the compilation of a snippet fails, the library displays the code snippet with the lines with compilation errors highlighted.
  • Currently I have to parse the diagnosticText to do this which is problematic:
    • The message format keeps changing which breaks the parser
    • I have to handle both coloured and non-coloured outputs which are formatted slightly differently

Alternatives you've considered

  • N/A

Additional context

  • N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions