Definitelytyped: [@types/tabulator-tables] the newest typescript 3.7.2 error: is not a module.

Created on 28 Nov 2019  路  3Comments  路  Source: DefinitelyTyped/DefinitelyTyped

when i use typescript in vscode, version:3.7.2, it say "/@types/tabulator-tables/index.d.ts' is not a module .Vetur(2306)."

add "export default Tabulator;" to 'index.d.ts' can resloved it.
thanks!

Most helpful comment

Just wanted to re-up this issue. Still present in Typescript version 3.7.5; adding export default Tabulator; to the top of index.d.ts also fixed it for me.

All 3 comments

Just wanted to re-up this issue. Still present in Typescript version 3.7.5; adding export default Tabulator; to the top of index.d.ts also fixed it for me.

@cbianco96 That fix won't work if you need to run your project through a CI pipeline. Due to your local change to index.d.ts not being on the build server.

But you can override Tabulator's index file by adding your own custom typings to your project .Including the modified index.d.ts file in src/@types/tabulator-tables. For example:

"typeRoots": ["src/@types", "node_modules/@types"],

See: https://www.detroitlabs.com/blog/2018/02/28/adding-custom-type-definitions-to-a-third-party-library/

I've been struggling with this as well for a while, and finally got it to work. Had to do the following:

Added the following to tsconfig.json as suggested above.

"typeRoots": ["types", "node_modules/@types"],

Created a types/tabulator-tables/index.d.ts file that looks like this

declare module "tabulator-tables" {
    export default Tabulator;
}

In my code, I could then just do the following

import TabulatorTable from 'tabulator-tables';

const table = new TabulatorTable("#element", {});
Was this page helpful?
0 / 5 - 0 ratings