💻
How are you using Babel?
@babel/cli
Input code
export const a = <T>() => {}
Configuration file name
babel.config.mjs
Configuration
export default {
presets: [
[
"@babel/preset-env",
{
modules: false,
},
],
"@babel/preset-react",
"@babel/preset-typescript",
],
};
Current and expected behavior
The generic type declaration is recognized as a JSX element:
SyntaxError: /tmp/babel-error/demo.ts: Unexpected token `>`. Did you mean `>` or `{'>'}`? (1:24)
> 1 | export const a = <T>() => {}
| ^
2 |
at constructor (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:325:19)
at TypeScriptParserMixin.raise (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:6389:19)
at TypeScriptParserMixin.jsxReadToken (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:4371:16)
at TypeScriptParserMixin.getTokenFromCode (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:4683:12)
at TypeScriptParserMixin.getTokenFromCode (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:13346:11)
at TypeScriptParserMixin.nextToken (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:5630:10)
at TypeScriptParserMixin.next (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:5540:10)
at TypeScriptParserMixin.eat (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:5544:12)
at TypeScriptParserMixin.expect (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:6745:15)
at TypeScriptParserMixin.jsxParseOpeningElementAfterName (file:///tmp/babel-error/node_modules/@babel/parser/lib/index.js:4578:10) {
code: 'BABEL_PARSE_ERROR',
reasonCode: 'UnexpectedToken',
loc: Position { line: 1, column: 24, index: 24 },
pos: 24,
syntaxPlugin: 'jsx'
}
tsc correctly compile this file and it also worked with babel 7.
Environment
System:
OS: Linux 6.17 Ubuntu 25.10 25.10 (Questing Quokka)
Binaries:
Node: 25.8.0
npm: 11.11.0
pnpm: 11.1.3
npmPackages:
@babel/cli: ^8.0.1 => 8.0.1
@babel/preset-env: ^8.0.2 => 8.0.2
@babel/preset-react: ^8.0.1 => 8.0.1
@babel/preset-typescript: ^8.0.1 => 8.0.1
Possible solution
No response
Additional context
Discovered because @hey-api/openapi-ts generates files that use this syntax : https://github.com/hey-api/hey-api/blob/03f9c540272e822bc2afa971d050397929460c98/examples/openapi-ts-ky/src/client/client/utils.gen.ts#L14
💻
How are you using Babel?
@babel/cli
Input code
Configuration file name
babel.config.mjs
Configuration
Current and expected behavior
The generic type declaration is recognized as a JSX element:
tsccorrectly compile this file and it also worked with babel 7.Environment
System:
OS: Linux 6.17 Ubuntu 25.10 25.10 (Questing Quokka)
Binaries:
Node: 25.8.0
npm: 11.11.0
pnpm: 11.1.3
npmPackages:
@babel/cli: ^8.0.1 => 8.0.1
@babel/preset-env: ^8.0.2 => 8.0.2
@babel/preset-react: ^8.0.1 => 8.0.1
@babel/preset-typescript: ^8.0.1 => 8.0.1
Possible solution
No response
Additional context
Discovered because @hey-api/openapi-ts generates files that use this syntax : https://github.com/hey-api/hey-api/blob/03f9c540272e822bc2afa971d050397929460c98/examples/openapi-ts-ky/src/client/client/utils.gen.ts#L14