简体   繁体   English

如何将Kendo UI类型输入到TypeScript模块中

[英]How to import the Kendo UI typings into a TypeScript module

I work with Kendo UI for React, using TypeScript. 我使用TypeScript使用Kendo UI for React。 I am trying to import the Kendo UI typings for TypeScript using a "typeof import". 我正在尝试使用“ typeof import”为TypeScript导入Kendo UI类型。

Following the instructions at https://docs.telerik.com/kendo-ui/third-party/typescript I installed the kendo-ui typings: 按照https://docs.telerik.com/kendo-ui/third-party/typescript上的说明,我安装了kendo-ui类型:

npm install --save @types/kendo-ui

I added the line 我加了线

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

to my .tsx file. 到我的.tsx文件。

However, this gives me the error message 但是,这给了我错误信息

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

for the "import("kendo-ui")" bit. 对于“ import(“ kendo-ui”)“位。

Looking at that file in the node_modules directory, this indeed does not have imports or exports. 查看node_modules目录中的该文件,确实没有导入或导出。

How can I import the Kendo-UI TypeScript types into my .tsx module? 如何将Kendo-UI TypeScript类型导入到我的.tsx模块中?

As long as you have @types/kendo-ui installed and you haven't overridden the types compiler option, the TypeScript compiler should load the Kendo UI global declarations automatically. 只要您已安装@types/kendo-ui且没有覆盖types编译器选项,TypeScript编译器便应自动加载Kendo UI全局声明。 It looks like the grid class you are looking for is named kendo.ui.Grid , so you could write: 看起来您要查找的网格类名为kendo.ui.Grid ,因此您可以编写:

declare var Grid: kendo.ui.Grid;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM