-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Labels
Description
💻
- Would you like to work on a fix?
How are you using Babel?
Other (Next.js, Gatsby, vue-cli, ...)
Input code
import { generate } from '@babel/generator'
import { parse } from '@babel/parser'
const { program } = parse(
`type MaybePromise<T> = Promise<T> | (T extends any ? Promise<T> : never)`,
{ plugins: ['typescript'] },
)
const { code } = generate(program)
console.log(code)
// type MaybePromise<T> = Promise<T> | T extends any ? Promise<T> : never;
// it's different if re-parseConfiguration file name
No response
Configuration
N/A
Current and expected behavior
Current:
type MaybePromise<T> = Promise<T> | T extends any ? Promise<T> : never;Expected:
type MaybePromise<T> = Promise<T> | (T extends any ? Promise<T> : never);Environment
N/A
Possible solution
Add brackets in generated code.
Additional context
downstream issue: sxzz/rolldown-plugin-dts#167
relate: #9546
Reactions are currently unavailable