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

[TS] Multiple "as" in assignment expression don't get transformed #7193

Closed
maaz93 opened this Issue Jan 10, 2018 · 5 comments

Comments

Projects
None yet
5 participants
@maaz93
Contributor

maaz93 commented Jan 10, 2018

This is a bug report.

Input Code

let a;
(a as number as any) = 42;

Babel/Babylon Configuration (.babelrc, package.json, cli command)

{
  "plugins": ["transform-typescript"]
}

Expected Behavior

let a;
a = 42;

TS Playground: Link

Current Behavior

Throws an error

TypeError: Property left of AssignmentExpression expected node to be of a type ["LVal"] but instead got "TSAsExpression"

Context

Was trying out the transforms after #7098. I seem to remember that this input worked before, because I think I tried this out in the REPL. But I don't remember too well. I can see that the parser results in the right AST, as per the tests in the PR and my knowledge.

Your Environment

software version(s)
Babel 7.0.0-beta.37 (latest master)
Babylon
node 8.9.3
npm 5.5.1
Operating System Windows 10
@babel-bot

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Jan 10, 2018

Collaborator

Hey @maaz93! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

Collaborator

babel-bot commented Jan 10, 2018

Hey @maaz93! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Show comment
Hide comment
@nicolo-ribaudo

nicolo-ribaudo Jan 10, 2018

Member

I seem to remember that this input worked before, because I think I tried this out in the REPL

It wasn't even parsed before your PR 😛

Member

nicolo-ribaudo commented Jan 10, 2018

I seem to remember that this input worked before, because I think I tried this out in the REPL

It wasn't even parsed before your PR 😛

@maaz93

This comment has been minimized.

Show comment
Hide comment
@maaz93

maaz93 Jan 10, 2018

Contributor

Ah ok. 😛 Then I think I must have have tried something else. Can I take a stab at this? You think you could point me to a starting point?

Contributor

maaz93 commented Jan 10, 2018

Ah ok. 😛 Then I think I must have have tried something else. Can I take a stab at this? You think you could point me to a starting point?

@nicolo-ribaudo

This comment has been minimized.

Show comment
Hide comment
@nicolo-ribaudo

nicolo-ribaudo Jan 10, 2018

Member

You can look in babel-types, you should update add LVal as an alias to TSAsExpression

Member

nicolo-ribaudo commented Jan 10, 2018

You can look in babel-types, you should update add LVal as an alias to TSAsExpression

@simonbuchan

This comment has been minimized.

Show comment
Hide comment
@simonbuchan

simonbuchan Jan 10, 2018

@nicolo-ribaudo but e as T doesn't have to be an l-value? e.g. (foo() as number) = 123; gives a friendly error - but maybe that's validated later. Just make sure that (foo() as any as number) = 123; isn't accepted with that change, I guess.

simonbuchan commented Jan 10, 2018

@nicolo-ribaudo but e as T doesn't have to be an l-value? e.g. (foo() as number) = 123; gives a friendly error - but maybe that's validated later. Just make sure that (foo() as any as number) = 123; isn't accepted with that change, I guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment