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

Bare "type" used as expression statement without semicolon causes syntax error #8073

Closed
jakebailey opened this issue Oct 6, 2023 · 2 comments · Fixed by #8263
Closed

Bare "type" used as expression statement without semicolon causes syntax error #8073

jakebailey opened this issue Oct 6, 2023 · 2 comments · Fixed by #8263
Assignees
Labels
Milestone

Comments

@jakebailey
Copy link

Describe the bug

This is code that appears on DefinitelyTyped; type in this context is just an expression statement, not a keyword. Adding a semicolon fixes the problem, though in this case, we are hitting this bug because DT is now formatting with dprint, which can't parse the tree to add the semicolon.

Input code

avplay.setListener({
  onsubtitlechange: (duration, subtitles, type, attributes) => {
      duration // $ExpectType string
      subtitles // $ExpectType string
      type // $ExpectType string
      attributes // $ExpectType AVPlaySubtitleAttribute[]
  }
})

Config

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": false
    },
    "target": "es2022",
    "loose": false,
    "minify": {
      "compress": false,
      "mangle": false
    }
  },
  "module": {
    "type": "es6"
  },
  "minify": false,
  "isModule": "unknown"
}

Playground link (or link to the minimal reproduction)

https://play.swc.rs/?version=1.3.74&code=H4sIAAAAAAAAA0ssK8hJrNQrTi3xySwuSc1LLdKo5uVSUMjPKy5NKsksyUlNzkjMS0%2B1UtBIKS1KLMnMz9NRgEkV6yiUVBak6igklpQUZSaVlqQWayrY2imATQABmBYFfX0FFdeKgtTkkhCgBoVioPK8dJgquHH4lYGswq8C4Qx0dY5hAUBvBkMtcoSpi44Faa3l5arVBAAunNNbCQEAAA%3D%3D&config=H4sIAAAAAAAAA1VPOw7DIAzdOQXy3KFi6NA79BCIOhEtP2GiFkW5eyCBtNns9%2FF7nhnn8CIFdz6XsSxBRsJ47AWh7JL8FgRSDkgq6pDg0tlElRqkIdygZWcgyThiqi4kcRWiOcB4T9gdDbPa6SH%2FZypvQ0Sis7BKpRsNnhNZSwXrn9NGtl9q373BDX6iHnYcBk2P7oTJvZ3%2FOGDLCgEeJWgcAQAA

SWC Info output

No response

Expected behavior

This code parses; type can just be an identifier in an expression statement.

Actual behavior

Parse error.

Version

1.3.74

Additional context

No response

@jakebailey
Copy link
Author

Likely, this is some missing ASI rule.

@swc-bot
Copy link
Collaborator

swc-bot commented Dec 21, 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 Dec 21, 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