[Bug]: Edge case in TSX: `<T,>(t: T) => t`
See original GitHub issue💻
- Would you like to work on a fix?
How are you using Babel?
Programmatic API (babel.transform
, babel.parse
)
Input code
const { transformSync } = require('@babel/core')
let result = transformSync(`
const fn = <T,>(t: T) => t;
`, {
babelrc: false,
configFile: false,
parserOpts: {
plugins: [
'jsx',
'typescript',
]
},
})
console.log(result.code)
Configuration file name
No response
Configuration
No response
Current and expected behavior
The current output:
const fn = <T>(t: T) => t;
This is valid in TS, but invalid in TSX, because <T>
is treated as a tag in TSX context.
Expected output:
const fn = <T,>(t: T) => t;
Environment
System:
OS: macOS 11.5.2
Binaries:
Node: 16.9.1 - /usr/local/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 7.23.0 - /usr/local/bin/npm
Possible solution
No response
Additional context
Original Issue: vitejs/vite#4949.
Issue Analytics
- State:
- Created 2 years ago
- Comments:19 (15 by maintainers)
Top Results From Across the Web
What Are Edge Cases in Software Testing? - 2022 Edition
Software testing edge cases are bugs that are uncommon for users to encounter. Edge cases can be minor - or as severe as...
Read more >What Is an Edge Case? Definition and Examples in a Product
An edge case is a type of bug in software development that only occurs under uncommon circumstances. This means that most users won't...
Read more >TSConfig Reference - Docs on every TSConfig option
From allowJs to useDefineForClassFields the TSConfig reference includes information about ... This means you won't accidentally ship a case fallthrough bug.
Read more >Migrating to React Query 4 - TanStack
The codemod is a best efforts attempt to help you migrate the breaking change. Please review the generated code thoroughly! Also, there are...
Read more >markdown-to-jsx - npm
options.overrides - Rendering Arbitrary React Components ... One of the most interesting use cases enabled by the HTML syntax processing in ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Okay, never mind then, probably it is related to my env. I actually started to dig in already, and it is going well and will update you soon I hope. Thanks
Yes,
yarn jest generator
works without problems on my machine 🤔