yoavbls / pretty-ts-errors

🔵 Make TypeScript errors prettier and human-readable in VSCode 🎀
https://marketplace.visualstudio.com/items?itemName=yoavbls.pretty-ts-errors
MIT License
13.44k stars 89 forks source link

Formatting error with single quotes inside a string literal type #61

Closed michaelstephendavies closed 1 year ago

michaelstephendavies commented 1 year ago

Describe the bug Hovering over the error in:

const x: "' 'Oh no" = null;

The formatting is broken

Type null is not assignable to type "'Oh no"'.

Expected behavior

Type null is not assignable to type "' 'Oh no".

Original error Type 'null' is not assignable to type '"' 'Oh no"'.ts(2322)

Screenshots

image
BalthazarB commented 1 year ago

I would like to fix this bug

yoavbls commented 1 year ago

@BalthazarB you're welcome to do it 🙂

MikeJakuszewski commented 1 year ago

Is this still open?

yoavbls commented 1 year ago

@MikeJakuszewski yes

MikeJakuszewski commented 1 year ago

@yoavbls, what is the expected behavior we want? Do we want to remove the inner quotes? I think I found the error, it is under format/addMissingParentheses.ts

yoavbls commented 1 year ago

@MikeJakuszewski The expected behavior is without removing the inner quotes: type null is not assignable to type "' 'Oh no"

You're welcome to try to fix it, and I can help in Discord if needed Unfortunately, I don't think it's the addMissingParentheses function because it should called only when a type ends with ...

yoavbls commented 1 year ago

I'm pretty sure I fixed all the cases of string literal types that did not escape properly here.

Give it a try with 0.5.2 and reopen this issue if you find new cases like this