问题描述
我刚刚下载了 TypeScript 文档.我有一些 JavaScript 类,我想在 TypeScript 测试应用程序中创建和使用这些类
I have just downloaded the TypeScript documentation. I have a some JavaScript classes and I would like to create and use these class in a TypeScript test application
如何从 TypeScript 调用包含 JavaScript 的 JavaScript 函数.我不想创建d.ts"文件.只是为了创建我的类,调用它的方法,访问它的属性.
How can I call a JavaScript function of an included JavaScript from TypeScript. I do not want to create a "d.ts" file. Just to create my classes, call its methods, access its properties.
我该怎么做?
我正在尝试将 kendoUI 与 TypeScript 结合使用.
I am trying to use kendoUI with TypeScript.
例如要显示一个窗口,我必须这样做:
For instance to show a window I have to do:
- 有一个 HTML 来表示窗口的内容.我有一个带有 id logonDialog 的 div.这个div
最初是隐藏的; - 我创建了窗口:logonDlg.kendoWindow(logOnParams);
- 然后使用 jQuery 我显示 div:使用
logonDlg.show();
示例
var logonDlg = $("logonDialog");
if (!logonDlg.data("kendoWindow")) {
logonDlg.kendoWindow(logOnParams);
logonDlg.show();
}
它工作正常.JS 是按我的意愿生成的,但由于JQuery"类型的值上不存在kendoWindow"属性,因此我收到一个错误.
It is working OK. The JS is generated as I want but I receive an error since The property 'kendoWindow' does not exist on value of type 'JQuery'.
我怎样才能禁用这种错误.正如瑞安所说,我无法工作.
How can I disable this kind of error. I could not make, what Ryan said, to work.
推荐答案
你只要去做.TypeScript 不会阻止你.您将在编译器输出中看到警告,但 tsc
将生成您的 JS 文件就好了.
You just do it. TypeScript won't stop you. You will see warnings in the compiler output but tsc
will generate your JS file just fine.
这篇关于直接从 TypeScript 调用 JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!