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

Fails to parse TypeScript: 1 as number >= 0 #6976

Closed
Knagis opened this issue Feb 22, 2023 · 1 comment · Fixed by #7398
Closed

Fails to parse TypeScript: 1 as number >= 0 #6976

Knagis opened this issue Feb 22, 2023 · 1 comment · Fixed by #7398
Assignees
Labels
Milestone

Comments

@Knagis
Copy link

Knagis commented Feb 22, 2023

Describe the bug

using x as type >= y fails to transpile. Note that some other comparisons like > parse without errors.

Input code

console.log(1 as number >= 0);

Config

No response

Playground link

https://play.swc.rs/?version=1.3.36&code=H4sIAAAAAAAAA0vOzyvOz0nVy8lP1zBUSCxWyCvNTUotUrCzVTDQtOblAgDhuUDJIAAAAA%3D%3D&config=H4sIAAAAAAAAA0WNSwrDMAxE76J1FsWLLnKHHsK4SnDxD40CDcZ3rx1cspNmnp4qfeBorVSsgGVMOJPaL62kZ2E48UVpIUWPNhvArS9WdtaOMMzDmF6HnMETWCj65LdzyFyORRi4K5v28Cdbd8X8PkZQr3%2BX80ntdsw7j9cEVQ5uPx%2Bqcl%2B4AAAA

Expected behavior

successfully transpiled as

console.log(1 >= 0);

TS playground link: https://www.typescriptlang.org/play?#code/MYewdgziA2CmB00QHMAUBGABAQwpsArgLYBGsATpgHwC8mADAJQDcQA

Actual behavior


  x Expression expected
   ,-[input.ts:1:1]
 1 | console.log(1 as number >= 0);
   :                          ^
   `----


Caused by:
    0: failed to process js file
    1: Syntax Error

Version

1.3.36

Additional context

console.log(1 as number > 0);

transpiles without issue

@Knagis Knagis added the C-bug label Feb 22, 2023
@kdy1 kdy1 added this to the Planned milestone Feb 22, 2023
@kdy1 kdy1 self-assigned this May 16, 2023
kdy1 added a commit that referenced this issue May 16, 2023
@kdy1 kdy1 modified the milestones: Planned, v1.3.59 May 19, 2023
@swc-bot
Copy link
Collaborator

swc-bot commented Jun 18, 2023

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@swc-project swc-project locked as resolved and limited conversation to collaborators Jun 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging a pull request may close this issue.

3 participants