Consider collapsing multiple repeated type-related error messages when in --pretty · Issue #23393 · microsoft/TypeScript (original) (raw)

Search Terms: error message pretty collapsing

The TS team started a few conversations in TSConf 2018 about making TypeScript error messages more friendly to newcomers. One good first one to approach could be repeated, near-identical errors around the same type.

Code

For example, if a type is missing multiple times in the same file:

let a: MissingType; let b: MissingType; // .. let c: MissingType;

Expected behavior:

In a debatably perfect world, TypeScript could give a single error message for the repeated class of error:

src/index.ts Error TS2304: Cannot find name 'MissingType'.

1   let a: MissingType;
           ~~~~~~~~~~~
2   let b: MissingType;
           ~~~~~~~~~~~
4   let c: MissingType;
           ~~~~~~~~~~~

Actual behavior:

Three separate errors.

Perhaps a post-processing step in --pretty mode that receives all of a file's errors and smooshes them down when it can?

Some open questions: