mylesmmurphy / prettify-ts

Prettify TypeScript: Better Type Previews
https://marketplace.visualstudio.com/items?itemName=MylesMurphy.prettify-ts
MIT License
203 stars 6 forks source link

Ambiguous array type: "number | null[]" should be "(number | null)[]" #29

Open birgersp opened 1 month ago

birgersp commented 1 month ago

Having some code like this:

const row: { values: (number | null)[] } = { values: [] }

The type is (explicitly) an array of elements where each element is a number or a null, and not an array of numbers, or a null.

When hovering, the VS Code built-in "type viewer" (whatever it's called) correctly displays the type. But the extension type displays:

number | null[]

... which seems incorrect. The parantheses should be there so the type is unambiguous.

image

mylesmmurphy commented 1 month ago

Hey @birgersp! Thanks for bringing this to my attention. This is definitely being incorrectly displayed in the extension. I've addressed this in #31 and it will be included in the next release v0.1.6, prerelease here if you want to try it out: https://github.com/mylesmmurphy/prettify-ts/releases/tag/v0.1.6

I will close this out once it's fully tested and released 😄