TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher.
archfz opened this issue · comments
- Version: 1.2.34
- Rollup Version: 2.70.1
- Operating System and version (if applicable): ubuntu
- Node Version (if applicable): 12
- Typescript version: 3.9.10
- Does it work with
tsc
(if applicable): YES
Reproduction
I have a tsconfig with
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"*": ["*", "node_modules/@types/*", "node_modules/*/lib"]
},
"module": "es2020",
"target": "ES2017",
"sourceMap": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": false,
"skipLibCheck": true,
"strictNullChecks": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"jsx": "react",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"types": ["node", "cypress"],
"incremental": true
},
"typeRoots": ["node_modules/@types"],
"include": ["src"],
"exclude": ["node_modules"]
}
In rollup I have
ts({
tsconfig: 'tsconfig.json',
}),
And I get this error: [!] (plugin Typescript) TS2472: Spread operator in 'new' expressions is only available when targeting ECMAScript 5 and higher.
. Does not matter what target I set, it always fails with this error.
When running npx tsc --noEmit --incremental false
separately it works correctly (no errors).
Expected Behavior
Should compile normally.
Actual Behavior
Does not compile and gives tsc error.
Hi there,
Do you have a reproducible example you can share? A minimal code snippet that will produce this behavior? At a glance, this is not something I'm able to reproduce, so I would love to dig into it.
Hi again. I've set up a simple project with just your tsconfig, a simple rollup config, and a file that uses spread syntax inside a New expression, and it works just fine. Here is the repro: https://replit.com/@wessberg/rollup-plugin-ts-new-spread-1#dist/index.js
As such, I don't see that there's a problem with rollup-plugin-ts
here, but feel free to prepare a minimal repro and respond back to me here. I'll gladly take another look at it and see if I can help you out.
I have debugged this for so long. I finally found out that it was a package.json
config: "browserslist": "> 0.5%, not dead",
. And it wasn't even in the direct project, it was a lower nested project having it it.