cli-table3 icon indicating copy to clipboard operation
cli-table3 copied to clipboard

TypeScript complains on table.push()

Open max-block opened this issue 6 years ago • 2 comments

TypeScript complains on table.push().

Here is a test code:

import Table from "cli-table3"
const table = new Table({
  head: ["H1", "H2"]
})
table.push(["c1", "c2"])
console.log(table.toString())

Here is an error message:

tsc

src/t0-test.ts:6:1 - error TS2349: Cannot invoke an expression whose type lacks a call signature. Type '((...items: Cell[][]) => number) | ((...items: VerticalTableRow[]) => number) | ((...items: CrossTableRow[]) => number)' has no compatible call signatures.

6 table.push(["c1", "c2"])
  ~~~~~~~~~~~~~~~~~~~~~~~~

That code possible to compile and run with ts-ignore comment: It will works:

// @ts-ignore
table.push(["c1", "c2"])

TypeScript version: 3.1.2 tsconfig.json:

{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "lib": ["es2017"],
    "sourceMap": true,
    "outDir": "./dist",
    "strict": true,
    "moduleResolution": "node",
    "noUnusedLocals": true,
    "noUnusedParameters": true,
    "esModuleInterop": true
  },
  "include": ["src/**/*"]
}

max-block avatar Oct 10 '18 14:10 max-block

can you check if https://github.com/cli-table/cli-table3/pull/53 fixes your issue?

otherwise something like this should also resolve your issue for now:

const table = new Table({
  head: ["H1", "H2"]
}) as HorizontalTable

(I just noticed that #53 removed those type definitions though, but I'm hoping that we can bring them back before releasing another version)

Turbo87 avatar Oct 10 '18 15:10 Turbo87

@Turbo87 was this ever fixed?

OmgImAlexis avatar Sep 25 '21 13:09 OmgImAlexis