0
votes

New to typescript, try to follow the demo https://www.npmjs.com/package/cp-react-tree-table to use this control in my project, but get below information.

Try to search and seems it's related to module definition which confuse.

Hope someone can show me light.

import * as jQuery from 'jquery';
import TreeDataTable from 'cp-react-tree-table';

'TreeDataTable' is declared but its value is never read.ts(6133) Could not find a declaration file for module 'cp-react-tree-table'. 'path/node_modules/cp-react-tree-table/dist/index.js' implicitly has an 'any' type.

Try npm install @types/cp-react-tree-table if it exists or add a new declaration (.d.ts) file containing declare module 'cp-react-tree-table';ts(7016) Could not find a declaration file for module 'cp-react-tree-table'. path/node_modules/cp-react-tree-table/dist/index.js' implicitly has an 'any' type.

Try npm install @types/cp-react-tree-table if it exists or add a new declaration (.d.ts) file containing declare module 'cp-react-tree-table';ts(7016)

Could not find a declaration file for module 'cp-react-tree-table'

2

2 Answers

0
votes

Your module doesn't have a type definition. You should have install : @types/cp-react-tree-table but apparently it doesn't exist.

So you have to manualy create a file : "cp-react-tree-table.d.ts" containing the types.

You have examples of types definition here.

0
votes

Create a new file like cp-react-tree-table.d.ts then add the following content to resolve the error quickly, but it's unsafe.

    declare module "cp-react-tree-table" {
      let TreeDataTable: any;
      export default TreeDataTable;
    }

Also, make sure typescript honoring our declaration file.