Skip to content

tsx with generic should throw error but not #10598

Open
1 of 1 issue completed
Open
1 of 1 issue completed
@bvanjoi

Description

@bvanjoi

Describe the bug

The test case in fn issue_2339_1() contains tsx syntax that should be invalid, but SWC incorrectly parses it without errors.

Input code

// .tsx
const t = <T>() => {
            // 1
            /* 2 */
            test;
        };

Config

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

Link to the code that reproduces this issue

https://play.swc.rs/?version=1.12.0&code=H4sIAAAAAAAAA0vOzysuUShRsFWwCbHT0FSwtVOo5lJAAvr6CoaoAloKRgpa%2BihiRaklpUV5CobWcNFaawBMsUPDWgAAAA%3D%3D&config=H4sIAAAAAAAAA1WPTQ7CIBCF9z0FmbULNdGFd%2FAQBKcNhgJhpomk6d0L5UfdMd97b96wDkLAmxQ8xJqeafAyEIY%2BJ0LRsvwkAhw9kgraM5yaypQlDgseZCsCsAwTcg4hXc%2BXWw2AcY4w4VEawspmbfUYfyuVm31Aon9jtko7mZ4vjUNthdm9lkOsX8nnlgvu8DW1sr4YND1bsqzddoFla%2FwXAQAA

SWC Info output

Expected behavior

throw error.

Actual behavior

parse success.

Version

1.12.0

Additional context

reference: https://www.typescriptlang.org/play/?removeComments=true&jsx=1#code/MYewdgzgLgBLC8MA8AVAfACgJQ3mmA3gFAylnmkD0lMAjCRY5QFQwBMMzlDj5ATgFMoAVz5g6Abh4UAvhKA

Sub-issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions