Possible Duplicate:
How to require jquery via AMD in TypeScript
I created a project in TypeScript
. I use RequireJS
. Everything was working fine, until I need JQuery
...
This is my files structure:
As you can see, I have jquery-1.8.d.ts
file in the modules
folder. The .js
file for jQuery
is inside the lib
folder. When I import a module using the config file for RequireJS
:
/// <reference path="../modules/require.d.ts" />
/// <reference path="AppMain.ts" />
require.config({
baseUrl: '../',
paths: {
jquery: 'lib/jquery-1.8.3'
},
shim: {
jquery: {
exports: '$'
}
},
name: "app/AppMain",
out: "../!built/Test.js",
optimize: "none"
});
require(['jquery', 'app/AppMain',
],
($, main) => {
var appMain = new main.AppMain();
appMain.run();
});
... then it's imported in JavaScript
. What to do if I want it inside TypeScript
? I need to use JQuery
, JQueryStatic
and JQueryPromise
, declared inside .d.ts
file.
When I try simply import a new module, I get an error:
import JQueryExternal = module("../../../modules/jquery-1.8.d"); // error: The name does not exist in the currect scope. A module cannot be aliased to a non-module type
interface Test {
MyMethod(): JQueryPromise; // here's a sample usage
}
In the beginning I thought that the path is wrong, but I tried to move it inside classes
folder and next I imported it in such a way as the rest of classes. Same error:/
How to use jQuery
in TypeScript
in a way I want to? Is it possible?