Skip to content

tsc: Display source line and mark position where error occurred #4024

Closed
@darrylring

Description

@darrylring

It would be super helpful to see the source line with the position of the error marked in the output from tsc. I've done a very quick, naive implementation of this (darrylring/TypeScript@0dfcc3ad7d664f622fcd5f139759bd6801d50b5d) and it seems to work nicely:

$ node built/local/tsc.js tests/cases/compiler/errorOnContextuallyTypedReturnType.ts 
tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(1,5): error TS2322: Type '() => void' is not assignable to type '() => boolean'.
  Type 'void' is not assignable to type 'boolean'.
    >>> var n1: () => boolean = function () { }; // expect an error here
            ^~
tests/cases/compiler/errorOnContextuallyTypedReturnType.ts(2,37): error TS2355: A function whose declared type is neither 'void' nor 'any' must return a value or consist of a single 'throw' statement.
    >>> var n2: () => boolean = function ():boolean { }; // expect an error here
                                            ^~~~~~~

Metadata

Metadata

Labels

CommittedThe team has roadmapped this issueFixedA PR has been merged for this issueSuggestionAn idea for TypeScript

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions