-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
JS value being parsed as a TS type argument #36662
Comments
Duplicate of #33639, except that this was spotted in the wild. |
Thanks for the de-dupe - though I think there's a good point which is that this isn't a @shicks can you tell us more about why you ended up piping this through TypeScript? |
We have a The workaround here was to just turn off this option, but that could be a problem if there were also *.js sources written in ESnext sitting alongside viz.js and needing to be tested in an older browser. |
If only it were! The fun thing here is that this is valid TS syntax. |
TypeScript Version: 3.8.0-dev.20200205
Search Terms: emscripten "type arguments"
Code
The following code (I added the declaration) was found in the distribution package for viz.js: https://github.com/mdaines/viz.js/releases/download/v2.1.2/lite.render.js. This file is generated by emscripten, so the syntax is a little weird.
Expected behavior:
This is valid JavaScript and should have the same parse as JS.
Actual behavior:
If this is parsed as TS, the part between the
<
and the>
get pulled out as a type annotation, leavingwhich is clearly incorrect, as it's trying to call a number. If this is parsed as a JS file (with --allowJs), it produces an error:
Even if one makes the argument that this is not valid TS syntax, it should still parse the explicitly-JS input.
Playground Link:
https://www.typescriptlang.org/play/?ts=3.8.0-dev.20200205&ssl=1&ssc=1&pln=4&pc=2#code/CYUwxgNghgTiAEEQBd4G0DWAaeIdRzBwDsBdALnmIFcBbAIxBjVIG4AoASwDN4AKPhngAfeAAYAlPAA8-BKMkj+QhVIB8-KDNkBGAGzw1G-UslSA3u3jWbt22DTFDGgEyl4AXng6AzHoAsHAC+QA
Related Issues:
I was unable to find anything.
The text was updated successfully, but these errors were encountered: