microsoft / microsoft/TypeScript

Error output: difficult to understand multistorey errors

Open
#26,996 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Needs Proposal Suggestion
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

Incompatible type
var foo = {a: {b: {c: {d: 3}}}};
var bar: {a: {b: {c: {d: {e: number}}}}} = foo;

Instead of

Type '{ a: { b: { c: { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: number; }; }; }; }; }'.
  Types of property 'a' are incompatible.
    Type '{ b: { c: { d: number; }; }; }' is not assignable to type '{ b: { c: { d: { e: number; }; }; }; }'.
      Types of property 'b' are incompatible.
        Type '{ c: { d: number; }; }' is not assignable to type '{ c: { d: { e: number; }; }; }'.
          Types of property 'c' are incompatible.
            Type '{ d: number; }' is not assignable to type '{ d: { e: number; }; }'.
              Types of property 'd' are incompatible.
                Type 'number' is not assignable to type '{ e: number; }'.

Print something like that

Type '{ a: { b: { c: { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: { e: number; }; }; }; }; }'.
  Property 'a.b.c.d: number' is not assignable to 'a.b.c.d: {...}'
Missing property
var foo = {a: {b: {c: {d: 3}}}};
var bar: {a: {b: {c: {d: number, e: number}}}} = foo;
Type '{ a: { b: { c: { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: number; e: number; }; }; }; }'.
  Types of property 'a' are incompatible.
    Type '{ b: { c: { d: number; }; }; }' is not assignable to type '{ b: { c: { d: number; e: number; }; }; }'.
      Types of property 'b' are incompatible.
        Type '{ c: { d: number; }; }' is not assignable to type '{ c: { d: number; e: number; }; }'.
          Types of property 'c' are incompatible.
            Type '{ d: number; }' is not assignable to type '{ d: number; e: number; }'.
              Property 'e' is missing in type '{ d: number; }'.

vs

Type '{ a: { b: { c: { d: number; }; }; }; }' is not assignable to type '{ a: { b: { c: { d: number; e: number; }; }; }; }'.
  Property 'a.b.c.e: number' is missing
Incompatible function parameter
var foo = {a: {b: {c: {d(y: number, x: string, z: number) {}}}}};
var bar: {a: {b: {c: {d(y: number, x: number, z: number):void}}}} = foo;
Type '{ a: { b: { c: { d(y: number, x: string, z: number): void; }; }; }; }' is not assignable to type '{ a: { b: { c: { d(y: number, x: number, z: number): void; }; }; }; }'.
    Parameter 'a.b.c.d(...,x: string,...)' is not compatible to 'a.b.c.d(...,x: number,...)'
Incompatible function return
var foo = {a: {b: {c: {d(x: number) {}}}}};
var bar: {a: {b: {c: {d(x: number):Date}}}} = foo;
Type '{ a: { b: { c: { d(x: number): void; }; }; }; }' is not assignable to type '{ a: { b: { c: { d(x: number): Date; }; }; }; }'.      
   Return type of 'a.b.c.d(...): void' is not compatible to 'a.b.c.d(...): Date'

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the incompatible-type, missing-property, incompatible-parameter, and incompatible-return examples in the issue. Trace how TypeScript currently formats these nested diagnostics, then compare the output with the requested property-path format; done means the examples report concise paths while preserving the relevant incompatibility details.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.