Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
dist [jquery] Split up declarations to stay under GitHub limits. Improve d… Oct 18, 2018
test Dom fixes 2019 07 11 (#36837) Jul 11, 2019
v1 Deprecate which property in jquery/v1 as well Dec 19, 2018
v2 Backport signature merging for JQuery.find to v2 (#36897) Aug 15, 2019
JQuery.d.ts
JQueryStatic.d.ts [jquery] Fix ArrayLike handling for call signature. Dec 11, 2018
README.md Update README.md Jul 10, 2017
index.d.ts [jquery] Split up declarations to stay under GitHub limits. Improve d… Oct 18, 2018
jquery-tests.ts [jquery] Add support for drag events. (#37349) Aug 5, 2019
legacy.d.ts Deprecate char, charCode and keyCode in jquery/legacy.d.ts. Dec 19, 2018
misc.d.ts [jquery] Add support for drag events. (#37349) Aug 5, 2019
tsconfig.json Trim tsconfig files; move untested files to OTHER_FILES.txt (#40676) Nov 26, 2019
tslint.json [jquery] Split up declarations to stay under GitHub limits. Improve d… Oct 18, 2018

README.md

Usage

Global

When jQuery is globally available, you can use jQuery and $ directly.

Importing (with a global DOM available)

When you want to import jQuery as a module and have a global DOM available (e.g. browser and browser-like environments):

import jQuery = require('jquery');

Importing (without a global DOM available)

When you want to import jQuery as a module and do not have a global DOM available (e.g. Node.js environment):

import jQueryFactory = require('jquery');
const jQuery = jQueryFactory(window, true);

Note that while the factory function ignores the second parameter, it is required to get correct type declarations.

Project structure

Authoring type definitions for jQuery plugins

$.fn is represented by JQuery.

$ is represented by JQueryStatic.

Declare an interface that has the plugin's overloads as call signatures and static members as properties.

interface MyPlugin {
    settings: MyPluginSettings;
    
    (behavior: 'enable'): JQuery;
    (settings?: MyPluginSettings): JQuery;
}

interface MyPluginSettings {
    title?: string;
}

Then declare a property on JQuery with your plugin's type.

interface JQuery {
    myPlugin: MyPlugin;
}
You can’t perform that action at this time.