Recently, I've been encountering issues with getting jQueryUI to function properly. Strangely enough, prior to attempting to integrate jQueryUI, using jQuery alone worked perfectly fine.
The current problem I'm facing is receiving a "TypeError: jQuery is not a function(...)" error in Chrome, even though jquery is designated as a dependency in the require.config file.
No errors occur during the compilation from .ts to .js.
Here is my initApp.ts code:
/// <reference path="../../../typings/jqueryui/jqueryui.d.ts"/>
import * as jQuery from "jquery"; //Operates without any issues
import * as jQueryUI from "jquery-ui"; //Module cannot be found unless the d.ts file is modified
After compilation to js:
define(["require", "exports", "jquery-ui"], function (require, exports, jQuery) {...}
This is the content of jqueryui.d.ts:
/// <reference path="../jquery/jquery.d.ts"/>
declare module JQueryUI { <unmodified code>}
//Added this declare
declare module "jquery-ui" {
export = jQuery;
}
For 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: "jQuery",
},
"jquery-ui": {
//exports: "jQuery", //Even adding this line does not resolve the issue
deps: ["jquery"],
}
},
});
require(["./javascripts/initApp"]);
Directory Tree structure:
typings/
jquery/
jquery.d.ts
jqueryui/
jqueryui.d.ts
web/
components/
javascripts/
lib/
jquery-2.1.4.js
jquery-ui.js
require.js
initApp.js
initApp.ts
require.config.js
Links to complete d.ts files can be found here:
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jquery/index.d.ts (jquery V3.3)
https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jqueryui/index.d.ts (QueryUI V1.12)
If anyone could provide some assistance, it would be greatly appreciated.