如何为TypeScript文件创建模板?

3

我有以下内容:

(function ($) {
    /**
    * Opens a new modal window
    * @param object options an object with any of the following options
    * @return object the jQuery object of the new window
    */
    $.modal = function (options) {
        var settings = $.extend({}, $.modal.defaults, options),
            root = getModalDiv(),

我的代码中有:

///<reference path='jquery.d.ts' />
function alertWin(title, message) {
    $.modal({

出现了一个错误,提示:

在类型为“JQueryStatic”的值上不存在属性“modal”

要解决这个问题,我需要创建某种类型的模板文件吗?如果是这样,我该如何做?

1个回答

4
只需扩展JQueryStatic接口即可,可以在任何文件中完成,typescript会将它们合并。
interface JQueryStatic {
  modal( options );
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接