microsoft / microsoft/TypeScript

Error elaborations should not be de-duped

Open
#33,143 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

TypeScript Version: 3.5.1

Search Terms:

  • Error message different

Code

interface ExprData {
  mapper : () => unknown,
  blah : string,
}
interface Expr<DataT extends ExprData> {
  mapper : DataT["mapper"],
  blah : DataT["blah"],

  extra : number,
}

declare function where (
  callback : () => Expr<{
    mapper : () => boolean,
    blah : string,
  }>
) : void;

declare function getInvalidWhere () : Expr<{
  mapper : () => (boolean|null),
  blah : string,
}>;

/*
Type 'Expr<{ mapper: () => boolean | null; blah: string; }>' is not assignable to type 'Expr<{ mapper: () => boolean; blah: string; }>'.
  Type '{ mapper: () => boolean | null; blah: string; }' is not assignable to type '{ mapper: () => boolean; blah: string; }'.
    Types of property 'mapper' are incompatible.
      Type '() => boolean | null' is not assignable to type '() => boolean'.
        Type 'boolean | null' is not assignable to type 'boolean'.
          Type 'null' is not assignable to type 'boolean'.
*/
where(() => getInvalidWhere())
/*
  Expected: Same error as above,
  Actual:
    Type 'Expr<{ mapper: () => boolean | null; blah: string; }>' is not assignable to type
    'Expr<{ mapper: () => boolean; blah: string; }>'.
*/
where(() => getInvalidWhere())

Expected behavior:

  • Both errors should have the same error message, if they're in the same file.
  • Both errors should have the same error message, if they're in different files.

Actual behavior:

  • Both errors have different error messages in the same file.
  • Both errors have different error messages in different files.

Playground Link:

Playground

Related Issues:

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

No source file or test is named. Start by reproducing the two calls in the provided TypeScript example and compare diagnostics from the Playground or a local compiler, then trace the compiler's error elaboration and de-duplication path. Done means repeated elaborations retain the same full message in both the same-file and different-file cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.