Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Typescript type assertion using angle brackets compiled incorrectly [with reproduction] #7243

Closed
arty-name opened this issue Nov 3, 2021 · 1 comment

Comments

@arty-name
Copy link
Contributor

馃悰 bug report

I tried to use type assertion with angle brackets in my Typescript files, and Parcel compiled that to invalid code, throwing errors at runtime.

馃帥 Configuration (.babelrc, package.json, cli command)

There鈥檚 no configuration

yarn parcel build fail.ts pass.ts

馃 Expected Behavior

Parcel should strip type assertion without breaking the code:

(async()=>{const o=await new Promise((o=>setTimeout(o,10)));console.log(o)})();

馃槸 Current Behavior

Parcel produces the following code:

(async()=>{await new Promise((e=>setTimeout(e,10))),console.log(a)})();

馃拋 Possible Solution

No idea

馃敠 Context

I thought that <Type>x is clearer than x as Type, but I can still use the latter until the bug is fixed.

馃捇 Code Sample

// fail.ts
(async() => {
 const a = await new Promise(resolve => setTimeout(resolve, 10));
 console.log(<number>a);
})();

// pass.ts
(async() => {
 const a = await new Promise(resolve => setTimeout(resolve, 10));
 console.log(a);
})();

馃實 Your Environment

Software Version(s)
Parcel 2.0.0
Node v16.13.0
npm/Yarn 1.22.15
Operating System Ubuntu 21.10
@mischnic
Copy link
Member

mischnic commented Nov 7, 2021

This was already fixed (probably with #7114). It works correctly with the nightly (yarn add parcel@nightly -E)

@mischnic mischnic closed this as completed Nov 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants