strothj / react-app-rewire-typescript-babel-preset

Add TypeScript support to Create React App using @babel/preset-typescript
https://react-app-rewire-typescript-babel-preset.netlify.com
MIT License
52 stars 6 forks source link

Generic type arguments in JSX elements #16

Closed detrohutt closed 6 years ago

detrohutt commented 6 years ago

I'm trying to use the feature described in the release notes for ts 2.9 under the heading "Generic type arguments in JSX elements".

Whenever I use this feature, neither tsc nor my editor (VS Code 1.25.1) shows any errors. However, when I run yarn start CRA throws an error that simply says Failed to compile. and the path to the file where I used the new syntax.

Have you been able to successfully use this feature? I'm not entirely sure it has anything to do with your project.

Package versions
strothj commented 6 years ago

You'll need to pin the version of @babel-parser using the resolutions field in package.json. I know Yarn supports it, not sure about NPM. That's until hopefully CRA releases another beta with an updated parser.

The parser has additions for the new nodes for that feature.

"resolutions": {
  "@babel/parser": "^7.0.0-beta.55",
}
strothj commented 6 years ago

Might also have to do @babel/core.

detrohutt commented 6 years ago

Awesome, that got CRA to compile! (I did also have to do @babel/core) Unfortunately it caused another typescript error with a package on my server, but I think I can get that sorted out. Thanks for your help and quick response! :)