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

Nested generics in TSX script fail to compile #7580

Closed
alshdavid opened this issue Jun 26, 2023 · 5 comments · Fixed by #7582
Closed

Nested generics in TSX script fail to compile #7580

alshdavid opened this issue Jun 26, 2023 · 5 comments · Fixed by #7582
Assignees
Labels
Milestone

Comments

@alshdavid
Copy link

alshdavid commented Jun 26, 2023

Describe the bug

SWC errors when using nested generics in a .tsx file in a specific configuration.

SWC Playground
Typescript Playground

The code that fails:

const example = () => {
  return {
    func: callback<typeof something<Type1, Type2>>(options => null)
  };
};

SWC succeeds when the nested generics are externalised (playground)

type CallbackOptions = typeof something<Type1, Type2>

const example = () => {
  return {
    func: callback<CallbackOptions>(options => null)
  };
};

I have tried different variations to see where the problem is but they seem to compile as expected

const example = callback<typeof something<Type1, Type2>>(options => null)

Settings

{
  "jsc": {
    "parser": {
      "syntax": "typescript",
      "tsx": true
    },
    "target": "es2022",
    "minify": {
      "compress": false
    },
  },
  "module": {
    "type": "es6"
  }
}

Expected behavior

To strip the types

Additional Info

This started happening with version 1.3.59 but was passing prior to that

playground 1.3.58
playground 1.3.59

Version

1.3.66

@kdy1 kdy1 closed this as not planned Won't fix, can't repro, duplicate, stale Jun 26, 2023
@kdy1
Copy link
Member

kdy1 commented Jun 26, 2023

Closing as duplicate

@alshdavid
Copy link
Author

@kdy1 Are you referencing #7187

My test case passes when placed in the same configuration. I am not sure if that means it has a different cause.

playground

@kdy1
Copy link
Member

kdy1 commented Jun 26, 2023

My bad. I didn't read it carefully. Sorry for the mistake.

@kdy1 kdy1 reopened this Jun 26, 2023
@kdy1 kdy1 added this to the Planned milestone Jun 26, 2023
@kdy1 kdy1 self-assigned this Jun 26, 2023
@alshdavid
Copy link
Author

All good, thanks for re-evaluating!

@swc-bot
Copy link
Collaborator

swc-bot commented Jul 29, 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 Jul 29, 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