Troubleshooting
-
Does tsc have the same output? If so, please explain why this is incorrect behavior
tsc only reports the error once.
-
Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate
Yes
-
Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction
https://stackblitz.com/edit/rpt2-repro-nzp9odzw?file=src%2Findex.ts
What happens and why it is incorrect
When there's an type error in the code, it gets reported multiple times:
src/index.ts → bundle.js...
[!] (plugin rpt2) RollupError: There was an error during the build:
[plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.
6 foo('foo');
~~~~~
Additionally, handling the error in the 'buildEnd' hook caused the following error:
[plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.
6 foo('foo');
~~~~~
src/index.ts
Error: There was an error during the build:
[plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.
6 foo('foo');
~~~~~
Additionally, handling the error in the 'buildEnd' hook caused the following error:
[plugin rpt2] src/index.ts:6:5 - error TS2345: Argument of type 'string' is not assignable to parameter of type 'number[]'.
6 foo('foo');
~~~~~
at getRollupError (/home/projects/rpt2-repro/node_modules/rollup/dist/shared/parseAst.js:289:41)
at <anonymous> (/home/projects/rpt2-repro/node_modules/rollup/dist/shared/rollup.js:24220:51)
Environment
Versions
System:
OS: Linux 5.0 undefined
CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 0 Bytes / 0 Bytes
Shell: 1.0 - /bin/jsh
Binaries:
Node: 22.22.0 - /usr/local/bin/node
Yarn: 1.22.19 - /usr/local/bin/yarn
npm: 10.8.2 - /usr/local/bin/npm
pnpm: 8.15.6 - /usr/local/bin/pnpm
npmPackages:
@rollup/wasm-node: 4.60.3
rollup-plugin-typescript2: ^0.37.0 => 0.37.0
typescript: ^5.9.3 => 5.9.3
rollup.config.js
:
import commonjs from '@rollup/plugin-commonjs';
import resolve from '@rollup/plugin-node-resolve';
import typescript from 'rollup-plugin-typescript2';
import terser from '@rollup/plugin-terser';
export default {
input: 'src/index.ts',
output: {
file: 'bundle.js',
format: 'iife',
sourcemap: true,
sourcemapFileNames: 'bundle.jsmap',
plugins: [
terser({
compress: {
drop_debugger: false,
},
}),
],
},
context: 'window',
plugins: [
commonjs({
include: 'node_modules/**',
ignoreGlobal: false,
sourceMap: false,
}),
resolve(),
typescript({
clean: true,
outputToFilesystem: true
}),
],
};
tsconfig.json
:
{
"compilerOptions": {
"incremental": true,
"tsBuildInfoFile": "./Build/tsbuildinfo.json",
"target": "es2020",
"sourceMap": true,
"module": "es6",
"moduleResolution": "bundler",
"noEmit": true,
"noEmitOnError": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitAny": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"strictBindCallApply": true,
"strictPropertyInitialization": true,
"noImplicitThis": true,
"useUnknownInCatchVariables": true,
"alwaysStrict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"exactOptionalPropertyTypes": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true,
"noImplicitOverride": true,
"noPropertyAccessFromIndexSignature": true,
"allowUnusedLabels": false,
"allowUnreachableCode": false,
"skipLibCheck": true,
}
}
package.json
:
{
"name": "test",
"version": "1.0.0",
"description": "",
"author": "",
"license": "UNLICENSED",
"type": "module",
"devDependencies": {
"@rollup/plugin-commonjs": "^29.0.1",
"@rollup/plugin-node-resolve": "^16.0.3",
"@rollup/plugin-terser": "^1.0.0",
"rollup": "^4.59.0",
"rollup-plugin-typescript2": "^0.37.0",
"source-map": "^0.7.6",
"tsc": "^2.0.4",
"tslib": "^2.8.1",
"typescript": "^5.9.3"
},
"scripts": {
"build": "npx rollup --config rollup.config.mjs"
}
}
Troubleshooting
Does
tschave the same output? If so, please explain why this is incorrect behaviortsc only reports the error once.
Does your Rollup plugin order match this plugin's compatibility? If not, please elaborate
Yes
Can you create a minimal example that reproduces this behavior? Preferably, use this environment for your reproduction
https://stackblitz.com/edit/rpt2-repro-nzp9odzw?file=src%2Findex.ts
What happens and why it is incorrect
When there's an type error in the code, it gets reported multiple times:
Environment
Versions
:rollup.config.js
:tsconfig.json
:package.json{ "name": "test", "version": "1.0.0", "description": "", "author": "", "license": "UNLICENSED", "type": "module", "devDependencies": { "@rollup/plugin-commonjs": "^29.0.1", "@rollup/plugin-node-resolve": "^16.0.3", "@rollup/plugin-terser": "^1.0.0", "rollup": "^4.59.0", "rollup-plugin-typescript2": "^0.37.0", "source-map": "^0.7.6", "tsc": "^2.0.4", "tslib": "^2.8.1", "typescript": "^5.9.3" }, "scripts": { "build": "npx rollup --config rollup.config.mjs" } }