New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JSDoc unexpected type error when spreading array containing different shapes of same type #58437
Comments
It behaves the same way but you need to make sure to enable I find it confusing that the TS playground for JS files uses |
Ah yes you're right, the issue only appears when |
You can replace your |
π Search Terms
"typescript jsdoc error spread union", "jsdoc error spread type different shape"
π Version & Regression Information
I was unable to test this on prior versions because the TS playground doesn't handle JSDoc
β― Playground Link
https://www.typescriptlang.org/play/?ts=5.4.5#code/FASwdgLgpgTgZgQwMZQAQGED2YAmIIjbqoDewqFqSAXKgM4QzgDmA3OZQEYD8tYUAN1jsAvsFCRYiFBmx4C2AEKkOFJL1T8hMdpVSdaWMHBBtgY4BACeABzRGTzVAF5ZufITDKAPm-mf0cSRsBlRoUNcACmDjU0NsRwBtAF0AShcAPlREABs6KHE4AFcwJAUwVBgoCCKYMABBOgBJCAAeABVbKAzIhBhmWk67VMGulQoqmrrUPrMLAHp51ABRAA87MqgceiKkFDo6SygGSMSSfVpzmlQAIiQb1BFHtPZwiFPzg1IL7+u7h6egJe4jep2AAEhPpcqLR-o9HgAaCFQ75fK6w+7wwHAYHARYrdZQTbbRAgHJHE5nZ6pViofEABRgmDsMGsqAA5Jx2agQHRUABbXl0FgU95UtFYl50paM5mwNmc7m8gVCkV4pYAVX4hOJ2QQZNQAHd8AALVAAKQAygARTBIBE7PbHPnGiBm9qW0VgyE-dG3TGApHggB0ocmtQazTFEJ9Er+AcRMZRyZh-oBWIhaRxNKAA
π» Code
The playground link contains the TS version, which work as expected, the below is the JSDoc equivalent throwing the unexpected type error:
π Actual behavior
With union type and recursion, when using a function that returns the same type as its input, an unexpected type error appear in some cases.
These pass:
But this fail:
π Expected behavior
I expect that all of the cases above pass as they do in TS, since the types are correct.
Additional information about the issue
VSCode version 1.89.0
TS version 5.4.5
This is tested with
checkJs
set astrue
.The text was updated successfully, but these errors were encountered: