【问题标题】:How to import the Kendo UI typings into a TypeScript module如何将 Kendo UI 类型导入 TypeScript 模块
【发布时间】:2019-02-05 01:21:57
【问题描述】:

我使用 TypeScript 为 React 使用 Kendo UI。我正在尝试使用“typeof import”为 TypeScript 导入 Kendo UI 类型。

按照以下说明进行操作 https://docs.telerik.com/kendo-ui/third-party/typescript 我安装了 kendo-ui 类型:

npm install --save @types/kendo-ui

我加了一行

declare var Grid: typeof import("kendo-ui");

到我的 .tsx 文件。

但是,这给了我错误信息

@types/kendo-ui/index.d.ts is not a module

对于"import("kendo-ui")" 位。

查看 node_modules 目录中的那个文件,这确实没有导入或导出。

如何将 Kendo-UI TypeScript 类型导入到我的 .tsx 模块中?

【问题讨论】:

    标签: typescript kendo-ui


    【解决方案1】:

    只要您安装了@types/kendo-ui 并且没有覆盖types 编译器选项,TypeScript 编译器就应该自动加载 Kendo UI 全局声明。看起来您要查找的网格类名为 kendo.ui.Grid,因此您可以这样写:

    declare var Grid: kendo.ui.Grid;
    

    【讨论】:

      猜你喜欢
      • 2020-12-10
      • 1970-01-01
      • 1970-01-01
      • 2015-08-05
      • 2017-12-07
      • 2020-06-27
      • 1970-01-01
      • 1970-01-01
      • 2017-05-04
      相关资源
      最近更新 更多