How to properly import jquery-ui into typescript file

I have included jquery like this

import $ = require('jquery');

      

and I am trying to make a div divable like this.

constructor() {
    $("#mydiv-id").draggable();
}

      

but i am getting error that draggable is not a function. I have jqueryui.d.ts, but how do I import it correctly?

require.config is like

var require = {
paths: {
    text: '../Scripts/libs/text',
    jquery: '../Scripts/libs/jquery-1.11.2',
    'jqueryui': '../Scripts/libs/jquery-ui',
    jscroll: '../Scripts/libs/jquery.jscroll', // and others

      

and I don't see any mention of jquerUI in the shim: section

+3


source to share


1 answer


You need it to link to your project. We recommend using tsconfig for this, which can generate the compilation context https://github.com/TypeStrong/atom-typescript/blob/master/docs/tsconfig.md

Example



{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "declaration": false,
        "noImplicitAny": false,
        "removeComments": true,
        "noLib": false
    },
    "filesGlob": [
        "./**/*.ts",
        "!./node_modules/**/*.ts"
    ],
    "files": [
        "./globals.ts",
        "./linter.ts",
        "./main/atom/atomUtils.ts",
        "./main/atom/autoCompleteProvider.ts",
        "./worker/messages.ts",
        "./worker/parent.ts",
        "./typings/jquery/jquery.d.ts",
    ]
}

      

0


source







All Articles