Skip to content

Error elaborations should not be de-duped #33143

Open
@AnyhowStep

Description

@AnyhowStep

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    Awaiting More FeedbackThis means we'd like to hear from more people who would be helped by this featureSuggestionAn idea for TypeScript

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions