我一直无法正常使用jQueryUI.在我尝试添加jQueryUI之前,单独使用jQuery就可以了.
使用下面的代码,我目前在chrome中得到"TypeError:jQuery不是函数(...)",这很奇怪,考虑到jquery在require.config文件中被标记为依赖项.
从.ts到.js的编译没有错误.
initApp.ts:
/// <reference path="../../../typings/jqueryui/jqueryui.d.ts"/>
import * as jQuery from "jquery"; //Works completely fine
import * as jQueryUI from "jquery-ui"; //Can't even find the module unless
//d.ts file is modified
Run Code Online (Sandbox Code Playgroud)
编译为js:
define(["require", "exports", "jquery-ui"], function (require, exports, jQuery) {...}
Run Code Online (Sandbox Code Playgroud)
jqueryui.d.ts:
/// <reference path="../jquery/jquery.d.ts"/>
declare module JQueryUI { <unmodified code>}
//Added this declare
declare module "jquery-ui" {
export = jQuery;
}
Run Code Online (Sandbox Code Playgroud)
Require.config.js:
require.config({
baseUrl: "./components/",
paths: {
"jquery": "./javascripts/lib/jquery-2.1.4",
"jquery-ui": "./javascripts/lib/jquery-ui",
"go": "./javascripts/lib/go-debug"
},
shim: {
"jquery": {
exports: …Run Code Online (Sandbox Code Playgroud)