@andraaspar/jquery-d-ts-3

Highly modular type definitions for the jQuery 3 API.


Keywords
TypeScript definition, jQuery 3, ES6, export default
License
MIT
Install
npm install @andraaspar/jquery-d-ts-3@1.0.0

Documentation

jQuery with highly modular TypeScript type definitions

  • Based on the API documentation for jQuery 3.1.
  • ES6 module compatible.
  • Separate interfaces defined for most objects / functions for easy reusability.
  • Most interface declarations are in separate files for easy browsing.
  • Usable in the Browser and in Node.
  • MIT licensed.

Usage

Bower

Installation:

bower install jquery-ts --save

Set up tsconfig.json:

{
    "compilerOptions": {
        "baseUrl": ".",
        "paths": {
            "*": [
                "bower_components/*",
                "*"
            ]
        }
    }
}

Then in TypeScript:

import $ from 'jquery-ts'

$(() => {
    $('body').append('<h1>Success!</h1>')
})

Node

Installation:

npm install jquery-ts --save
npm install jsdom --save
npm install @types/jsdom --save

Then in TypeScript:

import * as jsdom from 'jsdom'

import { initJQuery } from 'jquery-ts'

jsdom.env('<!DOCTYPE html>', (err, window) => {
    if (err) throw err

    let $ = initJQuery(window)

    $('body').append('<h1>Success!</h1>')
    console.log(jsdom.serializeDocument(window.document))
    // <!DOCTYPE html><html><head></head><body><h1>Success!</h1></body></html>
})