dmmulroy / ts-error-translator.nvim

MIT License
226 stars 5 forks source link

Error translating error for nested objects #20

Open richardalmee opened 6 months ago

richardalmee commented 6 months ago

Hi, thank you for your project ! I think I just stumbled upon an error in translating the errors for nested objects.

Here is some code that triggers the error

interface First {
  bar: {
    foo: string;
  }
}

interface Second {
  bar: {
    foo: number;
  }
}

let a: First = { bar: { foo: "hello" } }
let b: Second = { bar: { foo: 42 } };

a.bar = b.bar;

The error given on the last line is

Diagnostics:
1. Type '{ foo: number; }' is not assignable to type '{ foo: string; }'.
     Types of property 'foo' are incompatible.
       Type 'number' is not assignable to type 'string'.

   TypeScript Error Translation(s):
     • Something went wrong while translating your error. Please file an issue at https://github.com/dmmulroy/ts-error-translator.nvim and an example of the code that caused this error.
    [2322]
dmmulroy commented 6 months ago

Thank you for the report/issue and I'm sorry that you're running into this. This is related to #17. I did some naive parsing on new lines, hopefully a fix will be in shortly!

Also, kudos and many many thanks for the reproducible example 💜