-
-
Notifications
You must be signed in to change notification settings - Fork 613
Description
- Rollup Plugin Name: @rollup/plugin-typescript
- Rollup Plugin Version: 12.1.4
- Rollup Version: 4.18.0
- Operating System (or Browser): macOS, reproduction in StackBlitz
- Node Version: v20.11.1
- Link to reproduction: https://stackblitz.com/edit/rollup-repro-9whsjqk2?file=src%2Fmanager.js
Expected Behavior
With target: "ES2018", the TypeScript plugin should transform:
obj.prop?.nested→(obj.prop == null ? void 0 : obj.prop.nested)obj.timeout ??= value→obj.timeout = obj.timeout ?? value
Actual Behavior
When using @rollup/plugin-typescript with target: "ES2018", optional chaining (?.) and nullish coalescing assignment (??=) operators are not being transformed to ES2018-compatible syntax, even though these features were introduced in ES2020.
The optional chaining and nullish coalescing operators remain unchanged in the output, making the code incompatible with ES2018 environments.
This appears to be the case when .js files are involved in bundling. The attached example starts with a JavaScript file, but it's not clear to me if this issue will appear if you start bundling from a .ts file that imports something from a .js file as well.
Additional Information
I included a README in the StackBlitz reproduction with a few more details.