Skip to content

Branded type aware errors #20

@typeholes

Description

@typeholes

For example, the error message here doesn't point you towards needing a branded type

type FileName = string & {__brand: 'FN'};

type Errs = Record<FileName, string>;

const foo: Errs = {
  ['a' as 'a' & {__brand: 'FN'}]: 1,
  b: 1
}
Type '{ [x: string]: number; b: number; }' is not assignable to type 'Errs'.
  Object literal may only specify known properties, and 'b' does not exist in type 'Errs'.(2322)

It should be fairly easy to detect the branded type key and report something like

   Property 'b' is not branded 'FileName'

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions