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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

asi bug is not fixed #24

Closed
ChALkeR opened this issue Jul 31, 2024 · 5 comments · Fixed by #25
Closed

asi bug is not fixed #24

ChALkeR opened this issue Jul 31, 2024 · 5 comments · Fixed by #25

Comments

@ChALkeR
Copy link
Member

ChALkeR commented Jul 31, 2024

ref: swc-project/swc#9331

that fix is not complete

const x = 10 as number
(1)

is

"use strict";
const x = 10;
(1);

in typescript playground

But here it transforms into

const x = 10      
(1)

causing TypeError: 10 is not a function

While the snippet above causes a visible error, this one below will cause unexpected code to run silentely:

const y = () => () => console.log('unexpected')
const x = y as Function
(() => console.log('expected'))()

Seems to be an upstream bug?

@marco-ippolito
Copy link
Member

cc @kdy1

@kdy1
Copy link
Member

kdy1 commented Jul 31, 2024

I filed swc-project/swc#9355

@magic-akari
Copy link

This is more challenging than other ASI issues, because the 'as' expression isn't a standalone statement.
It must be fixed when it appears at the end of a statement, but it can also be found within an expression.

@magic-akari
Copy link

fixed in swc-project/swc#9358

@kdy1
Copy link
Member

kdy1 commented Aug 1, 2024

swc-project/swc#9358 is merged, and I published 1.7.4

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

Successfully merging a pull request may close this issue.

4 participants