1

For more context I've decided to keep all my modules in commonjs format for portability and use browserify with a few other things to bundle up stuff on the frontend.

I use TypeScript to do type checking but I'm not sure how to use jquery ui with my configuration. See below for a simple example.

package.json

{
  "main": "Main.js",
  "license": "MIT",
  "dependencies": {
    "@types/jquery": "^2.0.34",
    "@types/jqueryui": "^1.11.31"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "baseUrl": ".",
    "allowSyntheticDefaultImports": true,
    "outDir": "build/js",
    "target": "es5",
    "sourceMap": true,
    "noImplicitAny": true,
    "typeRoots": ["./node_modules/@types/*"]
  }
}

Main.ts

'use strict';
import $ from 'jquery'

export class Main {
    constructor(public app: string) {
        $(() => {
            $('#date').datepicker();
        })

    }
}

The error I get from the typescript compiler is Error:(7, 24) TS2339: Property 'datepicker' does not exist on type 'JQuery'. yet datepicker is defined in node_modules/@types/jqueryui/index.d.ts:1091.

So my question is how do I get jquery ui with commonjs working in typescript. I'm trying to keep from using triple slash directives (e.g. ///<reverence path="..." />

1 Answer 1

1

Try this:

import $ from "jquery";
declare var global: any
global.jQuery = $;
import "jqueryui";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.