Encountering this error is becoming a frequent occurrence for me, and I am currently unable to resolve it.
src/graphics.ts:105:55 - error TS2556: A spread argument must either have a
tuple type or be passed to a rest parameter.
105 _queue.forEach((_: any[]) => draw_ctx(this.ctx, ..._))
~~~~
Below is the snippet of code where the error arises:
export default class Graphics {
_queues: any
constructor(readonly ctx: number) {
this._queues = {}
}
flush() {
Object.keys(this._queues).map(color => {
let _queue = this._queues[color]
_queue.forEach((_: any[]) => draw_ctx(this.ctx, ..._))
})
}
}
function draw_ctx(ctx: number, _f: any, r: number, x: number, y: number, w: number, h: number, ...rest: any) {
console.log('hello')
}
Additionally, provided below is the content of tsconfig.json
:
{
"compilerOptions": {
"target": "ES2020",
"useDefineForClassFields": true,
"module": "ESNext",
"lib": ["ESNext", "DOM", "DOM.Iterable"],
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": true,
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
/* Linting */
"strict": true,
//"noUnusedLocals": true,
//"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true
},
"include": ["src"]
}