安装以下软件(从tables tables@4.9.1开始):
npm install tabulator-tables
npm install @types/tabulator-tables然后执行以下导入
import Tabulator from 'tabulator-tables';导致错误:Module Usage (Error node_modules @types tabulator tables index.d.ts' is not a module)。
改为使用此导入
import 'tabulator-tables';不输出错误,并允许加载类型信息,但在运行时(例如,在Angular 12项目上)实际上不允许访问制表器对象,从而导致像ReferenceError: Tabulator is not defined这样的错误。
发布于 2021-06-12 08:40:46
这是由于@types/tabulator-tables中的类型定义文件中缺少缺省导出。不幸的是,在上游添加默认导出是不可行的,因为它会破坏现有的代码库。
幸运的是,有一个解决方法,described here:创建一个index.d.ts文件,如果您还没有创建,并向其中添加以下行:
declare module "tabulator-tables" { export = Tabulator; }(还要确保将index.d.ts文件列在"files"中,或者确保它与tsconfig.json中的"includes"中的模式相匹配。您可能还需要在"compilerOptions"中设置"allowSyntheticDefaultImports": true。)
https://stackoverflow.com/questions/67916851
复制相似问题