1

jQuery 插件样板中,有一些很棒的 jQuery 插件开发起始代码,但是将这些代码复制并粘贴到打字稿中并进行编译会导致编译失败。

该错误来自undefined未(故意)调用的参数,因此问题是需要进行哪些修改才能使其编译。可以直接删除吗?

4

1 回答 1

2

设为undefined可选:

// the semi-colon before function invocation is a safety net against concatenated
// scripts and/or other plugins which may not be closed properly.
; (function ($ : any, window, document, undefined?) {

// undefined is used here as the undefined global variable in ECMAScript 3 is
// mutable (ie. it can be changed by someone else). undefined isn't really being
// passed in so we can ensure the value of it is truly undefined. In ES5, undefined
// can no longer be modified.

这将允许模板编译,因为未定义未传递到函数中。

于 2013-04-08T16:46:00.460 回答