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

[Presets: React + Typescript] Interface with generic method fails transpilation #7504

Closed
lukeggchapman opened this issue Mar 6, 2018 · 5 comments
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue

Comments

@lukeggchapman
Copy link

lukeggchapman commented Mar 6, 2018

bug report

Input Code

This is only an issue when using both the react and typescript presets.

interface I {
    <T>(p: T): T
}

Repl Link

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

{
    "presets": [
        "@babel/react",
        "@babel/typescript"
    ],
}

Expected Behavior

It should not throw and error.

Current Behavior

It throws:

{ SyntaxError: ./src/test.tsx: Unexpected token (2:4)

  1 | interface I {
> 2 |     <T>(p: T): T
    |     ^
  3 | }
  4 |

Possible Solution

Similar issue with generic methods: #6665
Similar fix for generic methods: #7225
Duplicate but closed Issue: #7158

Context

Your Environment

software version(s)
Babel 7.0.0-beta.40
preset-react 7.0.0-beta.40
preset-typescript 7.0.0-beta.40
node 8.9.0
npm 5.5.1
Operating System OSX
@babel-bot
Copy link
Collaborator

Hey @lukeggchapman! 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.

@jon-lp
Copy link

jon-lp commented Oct 4, 2018

+1 also encountering

@jon-lp
Copy link

jon-lp commented Oct 4, 2018

@lukeggchapman FWIW moving the function interface declaration into a separate file.d.ts file seemed to make everything happy:
– Webpack/Babel successfully compiles
– tsc type check works with that interface
– VSCode sees/follows it and has no errors/warnings
hope that helps!

@Tsury
Copy link

Tsury commented Nov 27, 2018

Also encountering this.

@danez
Copy link
Member

danez commented Nov 30, 2018

Fixed by #9058

@danez danez closed this as completed Nov 30, 2018
@lock lock bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 1, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated A closed issue/PR that is archived due to age. Recommended to make a new issue
Projects
None yet
Development

No branches or pull requests

5 participants