// tslint:disable:interface-name function JQuery() { function type_assertion() { const $el = $(document.createElement('canvas')); const $canvas = $el as JQuery; } function iterable() { for (const a of $('div')) { a.textContent = 'myDiv'; } } function arrayLike() { // $ExpectType HTMLElement $('div')[0]; $('div')[0] = new HTMLElement(); } function ajax() { function ajaxComplete() { // $ExpectType JQuery $(document).ajaxComplete(function(event, jqXHR, ajaxOptions) { // $ExpectType Document this; // $ExpectType Event event; // $ExpectType jqXHR jqXHR; // $ExpectType AjaxSettings ajaxOptions; return false; }); } function ajaxError() { // $ExpectType JQuery $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) { // $ExpectType Document this; // $ExpectType Event event; // $ExpectType jqXHR jqXHR; // $ExpectType AjaxSettings ajaxSettings; // $ExpectType string thrownError; return false; }); } function ajaxSend() { // $ExpectType JQuery $(document).ajaxSend(function(event, jqXHR, ajaxOptions) { // $ExpectType Document this; // $ExpectType Event event; // $ExpectType jqXHR jqXHR; // $ExpectType AjaxSettings ajaxOptions; return false; }); } function ajaxStart() { // $ExpectType JQuery $(document).ajaxStart(function() { // $ExpectType Document this; return false; }); } function ajaxStop() { // $ExpectType JQuery $(document).ajaxStop(function() { // $ExpectType Document this; return false; }); } function ajaxSuccess() { // $ExpectType JQuery $(document).ajaxSuccess(function(event, jqXHR, ajaxOptions, data) { // $ExpectType Document this; // $ExpectType Event event; // $ExpectType jqXHR jqXHR; // $ExpectType AjaxSettings ajaxOptions; // $ExpectType PlainObject data; return false; }); } function load() { // $ExpectType JQuery $('#result').load('/echo/html/', 'data', function(responseText, textStatus, jqXHR) { // $ExpectType HTMLElement this; // $ExpectType string responseText; // $ExpectType TextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType JQuery $('#result').load('/echo/html/', { data: 'data' }, function(responseText, textStatus, jqXHR) { // $ExpectType HTMLElement this; // $ExpectType string responseText; // $ExpectType TextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType JQuery $('#result').load('/echo/html/', function(responseText, textStatus, jqXHR) { // $ExpectType HTMLElement this; // $ExpectType string responseText; // $ExpectType TextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType JQuery $('#result').load('/echo/html/', 'data'); // $ExpectType JQuery $('#result').load('/echo/html/', { data: 'data' }); } } function attributes() { function attr() { // $ExpectType JQuery $('#greatphoto').attr('alt', 'Beijing Brush Seller'); // $ExpectType JQuery $('#greatphoto').attr('width', 200); // $ExpectType JQuery $('#greatphoto').attr('title', null); // $ExpectType JQuery $('#greatphoto').attr('alt', function(index, attr) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string attr; return 'Beijing Brush Seller'; }); // $ExpectType JQuery $('#greatphoto').attr('width', function(index, attr) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string attr; return 200; }); // $ExpectType JQuery $('#greatphoto').attr('title', function(index, attr) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string attr; }); // $ExpectType JQuery $('#greatphoto').attr('title', function(index, attr) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string attr; return undefined; }); // $ExpectType JQuery $('img').attr({ src: '/resources/hat.gif', title: 'jQuery', alt: 'jQuery Logo' }); // $ExpectType string | undefined $('img').attr('src'); } function removeAttr() { // $ExpectType JQuery $('#greatphoto').removeAttr('alt'); } } function properties() { function prop() { // $ExpectType JQuery $('p').prop('myProp', function(index, oldPropertyValue) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType any oldPropertyValue; return {}; }); // $ExpectType JQuery $('p').prop('myProp', {}); // $ExpectType JQuery $('input[type=\'checkbox\']').prop({ myProp: true }); // $ExpectType any $('input[type=\'checkbox\']').prop('myProp'); } function removeProp() { // $ExpectType JQuery $('p').removeProp('luggageCode'); } } function css() { // TODO: .css() getters can return 'undefined' for properties that don't exist. Consider changing the return types to reflect this after adding specialized signatures. function css() { // $ExpectType JQuery $('p').css('cssProp', 'value'); // $ExpectType JQuery $('p').css('cssProp', 20); // $ExpectType JQuery $('p').css('cssProp', function(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; return 'value'; }); // $ExpectType JQuery $('p').css('cssProp', function(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; return 20; }); // $ExpectType JQuery $('p').css('cssProp', function(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; }); // $ExpectType JQuery $('p').css('cssProp', function(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; return undefined; }); // $ExpectType JQuery $('p').css({ myProp1: 'value', myProp2: 20, myProp3(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; return 'value'; }, myProp4(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; return 20; }, myProp5(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; }, myProp6(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; return undefined; } }); // $ExpectType string $('p').css('myProp'); // $ExpectType PlainObject $('p').css([ 'myProp1', 'myProp2' ]); } function height() { // $ExpectType JQuery $('p').height('200px'); // $ExpectType JQuery $('p').height(400); // $ExpectType JQuery $('p').height(function(index, height) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number height; return '200px'; }); // $ExpectType JQuery $('p').height(function(index, height) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number height; return 400; }); // $ExpectType number | undefined $('p').height(); } function innerHeight() { // $ExpectType JQuery $('p').innerHeight('200px'); // $ExpectType JQuery $('p').innerHeight(400); // $ExpectType JQuery $('p').innerHeight(function(index, height) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number height; return '200px'; }); // $ExpectType JQuery $('p').innerHeight(function(index, height) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number height; return 400; }); // $ExpectType number | undefined $('p').innerHeight(); } function outerHeight() { // $ExpectType JQuery $('p').outerHeight('200px'); // $ExpectType JQuery $('p').outerHeight(400); // $ExpectType JQuery $('p').outerHeight(function(index, height) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number height; return '200px'; }); // $ExpectType JQuery $('p').outerHeight(function(index, height) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number height; return 400; }); // $ExpectType number | undefined $('p').outerHeight(); // $ExpectType number | undefined $('p').outerHeight(true); } function width() { // $ExpectType JQuery $('p').width('200px'); // $ExpectType JQuery $('p').width(400); // $ExpectType JQuery $('p').width(function(index, width) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number width; return '200px'; }); // $ExpectType JQuery $('p').width(function(index, width) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number width; return 400; }); // $ExpectType number | undefined $('p').width(); } function innerWidth() { // $ExpectType JQuery $('p').innerWidth('200px'); // $ExpectType JQuery $('p').innerWidth(400); // $ExpectType JQuery $('p').innerWidth(function(index, width) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number width; return '200px'; }); // $ExpectType JQuery $('p').innerWidth(function(index, width) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number width; return 400; }); // $ExpectType number | undefined $('p').innerWidth(); } function outerWidth() { // $ExpectType JQuery $('p').outerWidth('200px'); // $ExpectType JQuery $('p').outerWidth(400); // $ExpectType JQuery $('p').outerWidth(function(index, width) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number width; return '200px'; }); // $ExpectType JQuery $('p').outerWidth(function(index, width) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType number width; return 400; }); // $ExpectType number | undefined $('p').outerWidth(); // $ExpectType number | undefined $('p').outerWidth(true); } function offset() { // $ExpectType JQuery $('p').offset({ left: 20, top: 50 }); // $ExpectType JQuery $('p').offset(function(index, coords) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType Coordinates coords; return { left: 20, top: 50 }; }); // $ExpectType Coordinates | undefined $('p').offset(); } function position() { // $ExpectType Coordinates $('p').position(); } function scrollLeft() { // $ExpectType JQuery $('p').scrollLeft(200); // $ExpectType number $('p').scrollLeft(); } function scrollTop() { // $ExpectType JQuery $('p').scrollTop(200); // $ExpectType number $('p').scrollTop(); } function addClass() { // $ExpectType JQuery $('p').addClass('className'); // $ExpectType JQuery $('p').addClass(function(index, currentClassName) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string currentClassName; return 'className'; }); } function hasClass() { // $ExpectType boolean $('p').hasClass('className'); } function removeClass() { // $ExpectType JQuery $('p').removeClass('className'); // $ExpectType JQuery $('p').removeClass(function(index, currentClassName) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string currentClassName; return 'className'; }); // $ExpectType JQuery $('p').removeClass(); } function toggleClass() { // $ExpectType JQuery $('p').toggleClass('className', true); // $ExpectType JQuery $('p').toggleClass(function(index, className, state) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string className; // $ExpectType true state; return 'className'; }, true); // $ExpectType JQuery $('p').toggleClass('className'); // $ExpectType JQuery $('p').toggleClass(function(index, className, state) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string className; // $ExpectType boolean state; return 'className'; }); // $ExpectType JQuery $('p').toggleClass(false); // $ExpectType JQuery $('p').toggleClass(); } } function data() { function data() { // $ExpectType any $('p').data('myData', undefined); // $ExpectType JQuery $('p').data('myData', {}); // $ExpectType JQuery $('p').data({ myData1: {}, myData2: false }); // $ExpectType any $('p').data('myData'); // $ExpectType PlainObject $('p').data(); } function removeData() { // $ExpectType JQuery $('p').removeData('myData'); // $ExpectType JQuery $('p').removeData([ 'myData1', 'myData2' ]); // $ExpectType JQuery $('p').removeData(); } } function effects() { function animate() { // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }, 5000, 'linear', function() { // $ExpectType HTMLElement this; $(this).after('
Animation complete.
'); }); // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }, 5000, 'linear'); // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }, 5000, function() { // $ExpectType HTMLElement this; $(this).after('
Animation complete.
'); }); // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }, 'linear', function() { // $ExpectType HTMLElement this; $(this).after('
Animation complete.
'); }); // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }, 5000); // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }, 'linear'); // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }, function() { // $ExpectType HTMLElement this; $(this).after('
Animation complete.
'); }); // $ExpectType JQuery $('#book').animate({ width: 'toggle', height: 'toggle' }, { duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('#book').animate({ width: ['toggle', 'swing'], height: 200, opacity: 'toggle' }); } function fadeIn() { // $ExpectType JQuery $('p').fadeIn(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeIn(5000, 'linear'); // $ExpectType JQuery $('p').fadeIn(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeIn('linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeIn(5000); // $ExpectType JQuery $('p').fadeIn('linear'); // $ExpectType JQuery $('p').fadeIn(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeIn({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').fadeIn(); } function fadeOut() { // $ExpectType JQuery $('p').fadeOut(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeOut(5000, 'linear'); // $ExpectType JQuery $('p').fadeOut(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeOut('linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeOut(5000); // $ExpectType JQuery $('p').fadeOut('linear'); // $ExpectType JQuery $('p').fadeOut(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeOut({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').fadeOut(); } function fadeToggle() { // $ExpectType JQuery $('p').fadeToggle(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeToggle(5000, 'linear'); // $ExpectType JQuery $('p').fadeToggle(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeToggle('linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeToggle(5000); // $ExpectType JQuery $('p').fadeToggle('linear'); // $ExpectType JQuery $('p').fadeToggle(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeToggle({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').fadeToggle(); } function slideDown() { // $ExpectType JQuery $('p').slideDown(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideDown(5000, 'linear'); // $ExpectType JQuery $('p').slideDown(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideDown('linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideDown(5000); // $ExpectType JQuery $('p').slideDown('linear'); // $ExpectType JQuery $('p').slideDown(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideDown({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').slideDown(); } function slideToggle() { // $ExpectType JQuery $('p').slideToggle(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideToggle(5000, 'linear'); // $ExpectType JQuery $('p').slideToggle(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideToggle('linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideToggle(5000); // $ExpectType JQuery $('p').slideToggle('linear'); // $ExpectType JQuery $('p').slideToggle(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideToggle({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').slideToggle(); } function slideUp() { // $ExpectType JQuery $('p').slideUp(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideUp(5000, 'linear'); // $ExpectType JQuery $('p').slideUp(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideUp('linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideUp(5000); // $ExpectType JQuery $('p').slideUp('linear'); // $ExpectType JQuery $('p').slideUp(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').slideUp({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').slideUp(); } function fadeTo() { // $ExpectType JQuery $('p').fadeTo(5000, 0.9, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeTo(5000, 0.9, 'linear'); // $ExpectType JQuery $('p').fadeTo(5000, 0.9, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').fadeTo(5000, 0.9); } function toggle() { // $ExpectType JQuery $('p').toggle(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').toggle(5000, 'linear'); // $ExpectType JQuery $('p').toggle(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').toggle(5000); // $ExpectType JQuery $('p').toggle(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').toggle(true); // $ExpectType JQuery $('p').toggle(); } function hide() { // $ExpectType JQuery $('p').hide(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').hide(5000, 'linear'); // $ExpectType JQuery $('p').hide(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').hide(5000); // $ExpectType JQuery $('p').hide(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').hide({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').hide(); } function show() { // $ExpectType JQuery $('p').show(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').show(5000, 'linear'); // $ExpectType JQuery $('p').show(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').show(5000); // $ExpectType JQuery $('p').show(function() { // $ExpectType HTMLElement this; }); // $ExpectType JQuery $('p').show({ duration: 5000, specialEasing: { width: 'linear', height: 'easeOutBounce' }, complete() { $(this).after('
Animation complete.
'); } }); // $ExpectType JQuery $('p').show(); } } function queue() { function clearQueue() { // $ExpectType JQuery $('p').clearQueue('myQueue'); // $ExpectType JQuery $('p').clearQueue(); } function delay() { // $ExpectType JQuery $('p').delay('fast', 'myQueue'); // $ExpectType JQuery $('p').delay('slow'); } function dequeue() { // $ExpectType JQuery $('p').dequeue('myQueue'); // $ExpectType JQuery $('p').dequeue(); } function finish() { // $ExpectType JQuery $('p').finish('myQueue'); // $ExpectType JQuery $('p').finish(); } function queue() { // $ExpectType JQuery $('p').queue('myQueue', function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; }); // $ExpectType JQuery $('p').queue('myQueue', [ function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; }, function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; } ]); // $ExpectType JQuery $('p').queue(function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; }); // $ExpectType JQuery $('p').queue([ function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; }, function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; } ]); // $ExpectType Queue $('p').queue('myQueue'); // $ExpectType Queue $('p').queue(); } function stop() { // $ExpectType JQuery $('p').stop('myQueue', true, false); // $ExpectType JQuery $('p').stop('myQueue', true); // $ExpectType JQuery $('p').stop(true, false); // $ExpectType JQuery $('p').stop(true); } function promise() { // $ExpectType { description: string; } & Promise, any, any> $('p').promise('myQueue', { description: 'desc' }); // $ExpectType { description: string; } & Promise, any, any> $('p').promise({ description: 'desc' }); // $ExpectType Promise, any, any> $('p').promise(); } } function events() { // [bind() overloads] https://github.com/jquery/api.jquery.com/issues/1048 function bind() { // $ExpectType JQuery $('p').bind('myEvent', 'myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').bind('myEvent', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').bind('myEvent', false); // $ExpectType JQuery $('p').bind({ myEvent1(event) { // $ExpectType HTMLElement this; }, myEvent2: false }); // $ExpectType JQuery $('p').bind('myEvent', null); // $ExpectType JQuery $('p').bind('myEvent', undefined); } function delegate() { // $ExpectType JQuery $('table').delegate('td', 'myEvent', 'myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').delegate('td', 'myEvent', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').delegate('td', 'myEvent', false); // $ExpectType JQuery $('table').delegate('td', { myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }); } function off() { // $ExpectType JQuery $('table').off('myEvent', 'td', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').off('myEvent', 'td', false); // $ExpectType JQuery $('table').off('myEvent', 'td'); // $ExpectType JQuery $('table').off('myEvent', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').off('myEvent', false); // $ExpectType JQuery $('table').off('myEvent'); // $ExpectType JQuery $('table').off({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, 'td'); // $ExpectType JQuery $('table').off({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }); // $ExpectType JQuery $('table').off($.Event('myEvent')); // $ExpectType JQuery $('table').off(); } function on() { // $ExpectType JQuery $('table').on('myEvent', 'td', 'myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').on('myEvent', null, 'myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').on('myEvent', 'td', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').on('myEvent', 'td', false); // $ExpectType JQuery $('table').on('myEvent', 3, function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').on('myEvent', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').on('myEvent', false); // $ExpectType JQuery $('table').on({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, 'td', 'myData'); // $ExpectType JQuery $('table').on({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, null, 'myData'); // $ExpectType JQuery $('table').on({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, 'td'); // $ExpectType JQuery $('table').on({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, 3); // $ExpectType JQuery $('table').on({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }); } function one() { // $ExpectType JQuery $('table').one('myEvent', 'td', 'myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').one('myEvent', null, 'myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').one('myEvent', 'td', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').one('myEvent', 'td', false); // $ExpectType JQuery $('table').one('myEvent', 3, function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').one('myEvent', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').one('myEvent', false); // $ExpectType JQuery $('table').one({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, 'td', 'myData'); // $ExpectType JQuery $('table').one({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, null, 'myData'); // $ExpectType JQuery $('table').one({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, 'td'); // $ExpectType JQuery $('table').one({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }, 3); // $ExpectType JQuery $('table').one({ myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }); } function trigger() { // $ExpectType JQuery $('p').trigger('myEvent', ['Custom', 'Event']); // $ExpectType JQuery $('p').trigger('myEvent', { myData: 'myData' }); // $ExpectType JQuery $('p').trigger('myEvent', 'Custom'); // $ExpectType JQuery $('p').trigger('myEvent', 3); // $ExpectType JQuery $('p').trigger($.Event('myEvent'), ['Custom', 'Event']); // $ExpectType JQuery $('p').trigger($.Event('myEvent'), { myData: 'myData' }); // $ExpectType JQuery $('p').trigger($.Event('myEvent'), 'Custom'); // $ExpectType JQuery $('p').trigger($.Event('myEvent'), 3); } function triggerHandler() { // $ExpectType any $('p').triggerHandler('myEvent', ['Custom', 'Event']); // $ExpectType any $('p').triggerHandler('myEvent', { myData: 'myData' }); // $ExpectType any $('p').triggerHandler('myEvent', 'Custom'); // $ExpectType any $('p').triggerHandler('myEvent', 3); // $ExpectType any $('p').triggerHandler($.Event('myEvent'), ['Custom', 'Event']); // $ExpectType any $('p').triggerHandler($.Event('myEvent'), { myData: 'myData' }); // $ExpectType any $('p').triggerHandler($.Event('myEvent'), 'Custom'); // $ExpectType any $('p').triggerHandler($.Event('myEvent'), 3); } function unbind() { // $ExpectType JQuery $('p').unbind('myEvent', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').unbind('myEvent', false); // $ExpectType JQuery $('p').unbind('myEvent'); // $ExpectType JQuery $('p').unbind($.Event('myEvent')); // $ExpectType JQuery $('p').unbind(); } function undelegate() { // $ExpectType JQuery $('table').undelegate('td', 'click', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('table').undelegate('td', 'click', false); // $ExpectType JQuery $('table').undelegate('td', 'click'); // $ExpectType JQuery $('table').undelegate('td', { myEvent1(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, myEvent2: false }); // $ExpectType JQuery $('table').undelegate('.tt'); // $ExpectType JQuery $('table').undelegate(); } function blur() { // $ExpectType JQuery $('p').blur('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').blur(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').blur(false); // $ExpectType JQuery $('p').blur(); } function change() { // $ExpectType JQuery $('p').change('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').change(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').change(false); // $ExpectType JQuery $('p').change(); } function click() { // $ExpectType JQuery $('p').click('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').click(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').click(false); // $ExpectType JQuery $('p').click(); } function contextmenu() { // $ExpectType JQuery $('p').contextmenu('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').contextmenu(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').contextmenu(false); // $ExpectType JQuery $('p').contextmenu(); } function dblclick() { // $ExpectType JQuery $('p').dblclick('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').dblclick(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').dblclick(false); // $ExpectType JQuery $('p').dblclick(); } function focus() { // $ExpectType JQuery $('p').focus('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').focus(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').focus(false); // $ExpectType JQuery $('p').focus(); } function focusin() { // $ExpectType JQuery $('p').focusin('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').focusin(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').focusin(false); // $ExpectType JQuery $('p').focusin(); } function focusout() { // $ExpectType JQuery $('p').focusout('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').focusout(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').focusout(false); // $ExpectType JQuery $('p').focusout(); } function keydown() { // $ExpectType JQuery $('p').keydown('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').keydown(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').keydown(false); // $ExpectType JQuery $('p').keydown(); } function keypress() { // $ExpectType JQuery $('p').keypress('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').keypress(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').keypress(false); // $ExpectType JQuery $('p').keypress(); } function keyup() { // $ExpectType JQuery $('p').keyup('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').keyup(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').keyup(false); // $ExpectType JQuery $('p').keyup(); } function mousedown() { // $ExpectType JQuery $('p').mousedown('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mousedown(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mousedown(false); // $ExpectType JQuery $('p').mousedown(); } function mouseenter() { // $ExpectType JQuery $('p').mouseenter('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseenter(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseenter(false); // $ExpectType JQuery $('p').mouseenter(); } function mouseleave() { // $ExpectType JQuery $('p').mouseleave('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseleave(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseleave(false); // $ExpectType JQuery $('p').mouseleave(); } function mousemove() { // $ExpectType JQuery $('p').mousemove('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mousemove(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mousemove(false); // $ExpectType JQuery $('p').mousemove(); } function mouseout() { // $ExpectType JQuery $('p').mouseout('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseout(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseout(false); // $ExpectType JQuery $('p').mouseout(); } function mouseover() { // $ExpectType JQuery $('p').mouseover('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseover(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseover(false); // $ExpectType JQuery $('p').mouseover(); } function mouseup() { // $ExpectType JQuery $('p').mouseup('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseup(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').mouseup(false); // $ExpectType JQuery $('p').mouseup(); } function resize() { // $ExpectType JQuery $('p').resize('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').resize(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').resize(false); // $ExpectType JQuery $('p').resize(); } function scroll() { // $ExpectType JQuery $('p').scroll('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').scroll(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').scroll(false); // $ExpectType JQuery $('p').scroll(); } function select() { // $ExpectType JQuery $('p').select('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').select(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').select(false); // $ExpectType JQuery $('p').select(); } function submit() { // $ExpectType JQuery $('p').submit('myData', function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').submit(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').submit(false); // $ExpectType JQuery $('p').submit(); } function hover() { // $ExpectType JQuery $('p').hover(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').hover(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }, false); // $ExpectType JQuery $('p').hover(false, function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').hover(false, false); // $ExpectType JQuery $('p').hover(function(event) { // $ExpectType HTMLElement this; // $ExpectType Event event; }); // $ExpectType JQuery $('p').hover(false); } function ready() { // $ExpectType JQuery $('p').ready(($) => { // $ExpectType JQueryStatic $; }); } } function manipulation() { function after() { // $ExpectType JQuery $('p').after('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); // $ExpectType JQuery $('p').after(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return '

'; }); // $ExpectType JQuery $('p').after(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Element(); }); // $ExpectType JQuery $('p').after(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Text(); }); // $ExpectType JQuery $('p').after(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return [new Element(), new Text()]; }); // $ExpectType JQuery $('p').after(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return $('p'); }); } function append() { // $ExpectType JQuery $('p').append('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); // $ExpectType JQuery $('p').append(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return '

'; }); // $ExpectType JQuery $('p').append(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Element(); }); // $ExpectType JQuery $('p').append(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Text(); }); // $ExpectType JQuery $('p').append(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return [new Element(), new Text()]; }); // $ExpectType JQuery $('p').append(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return $('p'); }); // $ExpectType JQuery $('p').append($.parseHTML('myTextNode ')); } function before() { // $ExpectType JQuery $('p').before('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); // $ExpectType JQuery $('p').before(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return '

'; }); // $ExpectType JQuery $('p').before(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Element(); }); // $ExpectType JQuery $('p').before(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Text(); }); // $ExpectType JQuery $('p').before(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return [new Element(), new Text()]; }); // $ExpectType JQuery $('p').before(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return $('p'); }); } function prepend() { // $ExpectType JQuery $('p').prepend('

', new Element(), new Text(), $('p'), [new Element(), new Text()]); // $ExpectType JQuery $('p').prepend(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return '

'; }); // $ExpectType JQuery $('p').prepend(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Element(); }); // $ExpectType JQuery $('p').prepend(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return new Text(); }); // $ExpectType JQuery $('p').prepend(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return [new Element(), new Text()]; }); // $ExpectType JQuery $('p').prepend(function(index, html) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string html; return $('p'); }); } function appendTo() { // $ExpectType JQuery $('span').appendTo('p'); // $ExpectType JQuery $('span').appendTo('

'); // $ExpectType JQuery $('span').appendTo(new HTMLElement()); // $ExpectType JQuery $('span').appendTo([new HTMLElement()]); // $ExpectType JQuery $('span').appendTo($('p')); } function insertAfter() { // $ExpectType JQuery $('span').insertAfter('p'); // $ExpectType JQuery $('span').insertAfter('

'); // $ExpectType JQuery $('span').insertAfter(new HTMLElement()); // $ExpectType JQuery $('span').insertAfter([new HTMLElement()]); // $ExpectType JQuery $('span').insertAfter($('p')); } function insertBefore() { // $ExpectType JQuery $('span').insertBefore('p'); // $ExpectType JQuery $('span').insertBefore('

'); // $ExpectType JQuery $('span').insertBefore(new HTMLElement()); // $ExpectType JQuery $('span').insertBefore([new HTMLElement()]); // $ExpectType JQuery $('span').insertBefore($('p')); } function prependTo() { // $ExpectType JQuery $('span').prependTo('p'); // $ExpectType JQuery $('span').prependTo('

'); // $ExpectType JQuery $('span').prependTo(new HTMLElement()); // $ExpectType JQuery $('span').prependTo([new HTMLElement()]); // $ExpectType JQuery $('span').prependTo($('p')); } function clone() { // $ExpectType JQuery $('p').clone(true, true); // $ExpectType JQuery $('p').clone(true); // $ExpectType JQuery $('p').clone(); } function detach() { // $ExpectType JQuery $('p').detach('span'); // $ExpectType JQuery $('p').detach(); } function empty() { // $ExpectType JQuery $('p').empty(); } function remove() { // $ExpectType JQuery $('p').remove('span'); // $ExpectType JQuery $('p').remove(); } function replaceAll() { // $ExpectType JQuery $('p').replaceAll('span'); // $ExpectType JQuery $('p').replaceAll($('span')); // $ExpectType JQuery $('p').replaceAll(new HTMLElement()); // $ExpectType JQuery $('p').replaceAll([new HTMLElement()]); } function replaceWith() { // $ExpectType JQuery $('p').replaceWith(''); // $ExpectType JQuery $('p').replaceWith($('span')); // $ExpectType JQuery $('p').replaceWith(new HTMLElement()); // $ExpectType JQuery $('p').replaceWith([new HTMLElement()]); // $ExpectType JQuery $('p').replaceWith(function() { // $ExpectType HTMLElement this; return this; }); } function unwrap() { // $ExpectType JQuery $('p').unwrap('span'); // $ExpectType JQuery $('p').unwrap(); } function wrap() { // $ExpectType JQuery $('p').wrap('span'); // $ExpectType JQuery $('p').wrap(''); // $ExpectType JQuery $('p').wrap(new HTMLElement()); // $ExpectType JQuery $('p').wrap($('span')); // $ExpectType JQuery $('p').wrap(function(index) { // $ExpectType HTMLElement this; // $ExpectType number index; return ''; }); // $ExpectType JQuery $('p').wrap(function(index) { // $ExpectType HTMLElement this; // $ExpectType number index; return $('span'); }); } function wrapAll() { // $ExpectType JQuery $('p').wrapAll('span'); // $ExpectType JQuery $('p').wrapAll(''); // $ExpectType JQuery $('p').wrapAll(new HTMLElement()); // $ExpectType JQuery $('p').wrapAll($('span')); // $ExpectType JQuery $('p').wrapAll(function() { // $ExpectType HTMLElement this; return ''; }); // $ExpectType JQuery $('p').wrapAll(function() { // $ExpectType HTMLElement this; return $('span'); }); } function wrapInner() { // $ExpectType JQuery $('p').wrapInner('span'); // $ExpectType JQuery $('p').wrapInner(''); // $ExpectType JQuery $('p').wrapInner(new HTMLElement()); // $ExpectType JQuery $('p').wrapInner($('span')); // $ExpectType JQuery $('p').wrapInner(function(index) { // $ExpectType HTMLElement this; // $ExpectType number index; return ''; }); // $ExpectType JQuery $('p').wrapInner(function(index) { // $ExpectType HTMLElement this; // $ExpectType number index; return $('span'); }); // $ExpectType JQuery $('p').wrapInner(function(index) { // $ExpectType HTMLElement this; // $ExpectType number index; return new HTMLElement(); }); } function html() { // $ExpectType JQuery $('p').html(''); // $ExpectType JQuery $('p').html(function(index, oldhtml) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string oldhtml; return oldhtml; }); // $ExpectType string $('p').html(); } function text() { // $ExpectType JQuery $('p').text('myText'); // $ExpectType JQuery $('p').text(4); // $ExpectType JQuery $('p').text(true); // $ExpectType JQuery $('p').text(function(index, text) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string text; return 'myText'; }); // $ExpectType JQuery $('p').text(function(index, text) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string text; return 3; }); // $ExpectType JQuery $('p').text(function(index, text) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string text; return false; }); // $ExpectType string $('p').text(); } function val() { // $ExpectType JQuery $('p').val('myVal'); // $ExpectType JQuery $('p').val(5); // $ExpectType JQuery $('p').val(['myVal']); // $ExpectType JQuery $('p').val(function(index, value) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType string value; return 'myVal'; }); // $ExpectType string | number | string[] | undefined $('p').val(); } } function traversing() { function add() { // $ExpectType JQuery $('p').add('span', new HTMLElement()); // $ExpectType JQuery $('p').add('span'); // $ExpectType JQuery $('p').add(new HTMLElement()); // $ExpectType JQuery $('p').add([new HTMLElement()]); // $ExpectType JQuery $('p').add(''); // $ExpectType JQuery $('p').add($('span')); } function closest() { // $ExpectType JQuery $('p').closest('span', new HTMLElement()); // $ExpectType JQuery $('p').closest('span'); // $ExpectType JQuery $('p').closest(new HTMLElement()); // $ExpectType JQuery $('p').closest($('span')); } function find() { // $ExpectType JQuery $('p').find('span'); // $ExpectType JQuery $('p').find(new HTMLElement()); // $ExpectType JQuery $('p').find($('span')); } function addBack() { // $ExpectType JQuery $('p').addBack('span'); // $ExpectType JQuery $('p').addBack(); } function children() { // $ExpectType JQuery $('p').children('span'); // $ExpectType JQuery $('p').children(); } function siblings() { // $ExpectType JQuery $('p').siblings('span'); // $ExpectType JQuery $('p').siblings(); } function contents() { // $ExpectType JQuery $('p').contents(); } function end() { // $ExpectType JQuery $('p').end(); } function first() { // $ExpectType JQuery $('p').first(); } function last() { // $ExpectType JQuery $('p').last(); } function offsetParent() { // $ExpectType JQuery $('p').offsetParent(); } function filter() { // $ExpectType JQuery $('p').filter('span'); // $ExpectType JQuery $('p').filter(new HTMLElement()); // $ExpectType JQuery $('p').filter([new HTMLElement()]); // $ExpectType JQuery $('p').filter($('span')); // $ExpectType JQuery $('p').filter(function(index, element) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement element; return false; }); } function not() { // $ExpectType JQuery $('p').not('span'); // $ExpectType JQuery $('p').not(new HTMLElement()); // $ExpectType JQuery $('p').not([new HTMLElement()]); // $ExpectType JQuery $('p').not($('span')); // $ExpectType JQuery $('p').not(function(index, element) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement element; return false; }); } function is() { // $ExpectType boolean $('p').is('span'); // $ExpectType boolean $('p').is(new HTMLElement()); // $ExpectType boolean $('p').is([new HTMLElement()]); // $ExpectType boolean $('p').is($('span')); // $ExpectType boolean $('p').is(function(index, element) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement element; return false; }); } function next() { // $ExpectType JQuery $('p').next('span'); // $ExpectType JQuery $('p').next(); } function nextAll() { // $ExpectType JQuery $('p').nextAll('span'); // $ExpectType JQuery $('p').nextAll(); } function nextUntil() { // $ExpectType JQuery $('p').nextUntil('span', 'span'); // $ExpectType JQuery $('p').nextUntil(new HTMLElement(), 'span'); // $ExpectType JQuery $('p').nextUntil($('span'), 'span'); // $ExpectType JQuery $('p').nextUntil('span'); // $ExpectType JQuery $('p').nextUntil(new HTMLElement()); // $ExpectType JQuery $('p').nextUntil($('span')); // $ExpectType JQuery $('p').nextUntil(); } function prev() { // $ExpectType JQuery $('p').prev('span'); // $ExpectType JQuery $('p').prev(); } function prevAll() { // $ExpectType JQuery $('p').prevAll('span'); // $ExpectType JQuery $('p').prevAll(); } function prevUntil() { // $ExpectType JQuery $('p').prevUntil('span', 'span'); // $ExpectType JQuery $('p').prevUntil(new HTMLElement(), 'span'); // $ExpectType JQuery $('p').prevUntil($('span'), 'span'); // $ExpectType JQuery $('p').prevUntil('span'); // $ExpectType JQuery $('p').prevUntil(new HTMLElement()); // $ExpectType JQuery $('p').prevUntil($('span')); // $ExpectType JQuery $('p').prevUntil(); } function parent() { // $ExpectType JQuery $('p').parent('span'); // $ExpectType JQuery $('p').parent(); } function parents() { // $ExpectType JQuery $('p').parents('span'); // $ExpectType JQuery $('p').parents(); } function parentsUntil() { // $ExpectType JQuery $('p').parentsUntil('span', 'span'); // $ExpectType JQuery $('p').parentsUntil(new HTMLElement(), 'span'); // $ExpectType JQuery $('p').parentsUntil($('span'), 'span'); // $ExpectType JQuery $('p').parentsUntil('span'); // $ExpectType JQuery $('p').parentsUntil(new HTMLElement()); // $ExpectType JQuery $('p').parentsUntil($('span')); // $ExpectType JQuery $('p').parentsUntil(); } function eq() { // $ExpectType JQuery $('p').eq(0); } function has() { // $ExpectType JQuery $('p').has('span'); // $ExpectType JQuery $('p').has(new HTMLElement()); } function map() { // $ExpectType JQuery $('p').map(function(index, domElement) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement domElement; return 'myVal'; }); // $ExpectType JQuery $('p').map(function(index, domElement) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement domElement; return ['myVal1', 'myVal2']; }); // $ExpectType JQuery $('p').map(function(index, domElement) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement domElement; return null; }); // $ExpectType JQuery $('p').map(function(index, domElement) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement domElement; return undefined; }); } function slice() { // $ExpectType JQuery $('p').slice(0, 10); // $ExpectType JQuery $('p').slice(0); } function pushStack() { // $ExpectType JQuery $('p').pushStack([new HTMLElement()], 'name', ['arg']); // $ExpectType JQuery $('p').pushStack([new HTMLElement()]); } } function misc() { function serialize() { // $ExpectType string $('p').serialize(); } function serializeArray() { // $ExpectType NameValuePair[] $('p').serializeArray(); } function each() { // $ExpectType JQuery $('p').each(function(index, element) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement element; }); // $ExpectType JQuery $('p').each(function(index, element) { // $ExpectType HTMLElement this; // $ExpectType number index; // $ExpectType HTMLElement element; return false; }); } function extend() { // $ExpectType JQuery $.fn.extend({ myPlugin: {} }); } function get() { // $ExpectType HTMLElement $('p').get(0); // $ExpectType HTMLElement[] $('p').get(); } function index() { // $ExpectType number $('p').index('span'); // $ExpectType number $('p').index(new HTMLElement()); // $ExpectType number $('p').index($('span')); // $ExpectType number $('p').index(); } function toArray() { // $ExpectType HTMLElement[] $('p').toArray(); } } } function JQueryStatic() { function type_assertion() { const $Canvas = $ as JQueryStatic; } function type_annotation() { const jq: JQueryStatic = $; } function call_signature() { // $ExpectType JQuery $('

', new Document()); // $ExpectType JQuery $('

', { class: 'my-div', on: { touchstart() { // Do something } } }); // $ExpectType JQuery $('span', new HTMLElement()); // $ExpectType JQuery $('span', new Document()); // $ExpectType JQuery $('span', $('p')); // $ExpectType JQuery $('span'); // $ExpectType JQuery $('

'); // $ExpectType JQuery $(new HTMLElement()); // $ExpectType JQuery $([new HTMLElement()]); // $ExpectType JQuery $({ foo: 'bar', hello: 'world' }); // $ExpectType JQuery $($('p')); // $ExpectType JQuery $(function($) { // $ExpectType Document this; // $ExpectType JQueryStatic $; }); // $ExpectType JQuery $(); } function Event() { // $ExpectType EventStatic $.Event; } function cssHooks() { // $ExpectType PlainObject> $.cssHooks; } function cssNumber() { // $ExpectType PlainObject $.cssNumber; } function fn() { // $ExpectType JQuery $.fn; } function fx() { function interval() { // $ExpectType number $.fx.interval; } function off() { // $ExpectType boolean $.fx.off; } function step() { // $ExpectType PlainObject> $.fx.step; } } function ready() { // $ExpectType Thenable> $.ready; } function support() { // $ExpectType PlainObject $.support; } function valHooks() { // $ExpectType PlainObject> $.valHooks; } function Callbacks() { // $ExpectType Callbacks $.Callbacks('once'); // $ExpectType Callbacks $.Callbacks(); } function Deferred() { function call_signature() { // $ExpectType Deferred $.Deferred(function(deferred) { // $ExpectType Deferred this; // $ExpectType Deferred deferred; }); // $ExpectType Deferred $.Deferred(); // $ExpectType Deferred $.Deferred(function(deferred) { // $ExpectType Deferred this; // $ExpectType Deferred deferred; }); // $ExpectType Deferred $.Deferred(); // $ExpectType Deferred $.Deferred(function(deferred) { // $ExpectType Deferred this; // $ExpectType Deferred deferred; }); // $ExpectType Deferred $.Deferred(); // $ExpectType Deferred $.Deferred(function(deferred) { // $ExpectType Deferred this; // $ExpectType Deferred deferred; }); // $ExpectType Deferred $.Deferred(); } function exceptionHook() { $.Deferred.exceptionHook = undefined; } } function ajax() { // $ExpectType jqXHR $.ajax('url', { cache: true }); } function ajaxPrefilter() { // $ExpectType void $.ajaxPrefilter('dataTypes', (options, originalOptions, jqXHR) => { // $ExpectType AjaxSettings options; // $ExpectType AjaxSettings originalOptions; // $ExpectType jqXHR jqXHR; return 'filtered'; }); // $ExpectType void $.ajaxPrefilter('dataTypes', (options, originalOptions, jqXHR) => { // $ExpectType AjaxSettings options; // $ExpectType AjaxSettings originalOptions; // $ExpectType jqXHR jqXHR; }); // $ExpectType void $.ajaxPrefilter((options, originalOptions, jqXHR) => { // $ExpectType AjaxSettings options; // $ExpectType AjaxSettings originalOptions; // $ExpectType jqXHR jqXHR; return 'filtered'; }); // $ExpectType void $.ajaxPrefilter((options, originalOptions, jqXHR) => { // $ExpectType AjaxSettings options; // $ExpectType AjaxSettings originalOptions; // $ExpectType jqXHR jqXHR; }); } function ajaxSetup() { // $ExpectType AjaxSettings $.ajaxSetup({ cache: true }); } function ajaxTransport() { // $ExpectType void $.ajaxTransport('dataTypes', (options, originalOptions, jqXHR) => { // $ExpectType AjaxSettings options; // $ExpectType AjaxSettings originalOptions; // $ExpectType jqXHR jqXHR; return { send(headers, completeCallback) { // $ExpectType PlainObject headers; // $ExpectType SuccessCallback completeCallback; }, abort() { } }; }); // $ExpectType void $.ajaxTransport('dataTypes', (options, originalOptions, jqXHR) => { // $ExpectType AjaxSettings options; // $ExpectType AjaxSettings originalOptions; // $ExpectType jqXHR jqXHR; }); } function contains() { // $ExpectType boolean $.contains(new HTMLElement(), new HTMLElement()); } function css() { // $ExpectType any $.css(new HTMLElement(), {}); } function data() { // $ExpectType any $.data(new HTMLElement(), 'myKey', undefined); // $ExpectType "myValue" $.data(new HTMLElement(), 'myKey', 'myValue'); // $ExpectType any $.data(new HTMLElement(), 'myKey'); // $ExpectType any $.data(new HTMLElement()); } function dequeue() { // $ExpectType void $.dequeue(new HTMLElement(), 'myQueue'); // $ExpectType void $.dequeue(new HTMLElement()); } function each() { // $ExpectType ArrayLike $.each(['myVal1', 'myVal2'], function(index, val) { // $ExpectType string this; // $ExpectType number index; // $ExpectType string val; return false; }); // $ExpectType ArrayLike $.each(['myVal1', 'myVal2'], function(index, val) { // $ExpectType string this; // $ExpectType number index; // $ExpectType string val; return 10; }); // $ExpectType ArrayLike $.each(['myVal1', 'myVal2'], function(index, val) { // $ExpectType string this; // $ExpectType number index; // $ExpectType string val; }); // $ExpectType { myVal1: boolean; myVal2: () => 10; myVal3: string; } $.each({ myVal1: false, myVal2: () => { return 10; }, myVal3: 'myVal3' }, function(propertyName, valueOfProperty) { // $ExpectType string | boolean | (() => 10) this; // $ExpectType "myVal1" | "myVal2" | "myVal3" propertyName; // $ExpectType string | boolean | (() => 10) valueOfProperty; return false; }); // $ExpectType { myVal1: boolean; myVal2: () => 10; myVal3: string; } $.each({ myVal1: false, myVal2: () => { return 10; }, myVal3: 'myVal3' }, function(propertyName, valueOfProperty) { // $ExpectType string | boolean | (() => 10) this; // $ExpectType "myVal1" | "myVal2" | "myVal3" propertyName; // $ExpectType string | boolean | (() => 10) valueOfProperty; return 10; }); // $ExpectType { myVal1: boolean; myVal2: () => 10; myVal3: string; } $.each({ myVal1: false, myVal2: () => { return 10; }, myVal3: 'myVal3' }, function(propertyName, valueOfProperty) { // $ExpectType string | boolean | (() => 10) this; // $ExpectType "myVal1" | "myVal2" | "myVal3" propertyName; // $ExpectType string | boolean | (() => 10) valueOfProperty; }); } function error() { jQuery.error = console.error; } function escapeSelector() { // $ExpectType string $.escapeSelector('span'); } function extend() { const t = { name: 'myObj' }; const u = new EventTarget(); const v = new Node(); const w = new Comment(); const x = new Text(); const y = new Element(); const z = new HTMLElement(); const a = new SVGElement(); // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element & HTMLElement $.extend(true, t, u, v, w, x, y, z); // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element $.extend(true, t, u, v, w, x, y); // $ExpectType { name: string; } & EventTarget & Node & Comment & Text $.extend(true, t, u, v, w, x); // $ExpectType { name: string; } & EventTarget & Node & Comment $.extend(true, t, u, v, w); // $ExpectType { name: string; } & EventTarget & Node $.extend(true, t, u, v); // $ExpectType { name: string; } & EventTarget $.extend(true, t, u); // $ExpectType any $.extend(true, t, u, v, w, x, y, z, a); // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element & HTMLElement $.extend(t, u, v, w, x, y, z); // $ExpectType { name: string; } & EventTarget & Node & Comment & Text & Element $.extend(t, u, v, w, x, y); // $ExpectType { name: string; } & EventTarget & Node & Comment & Text $.extend(t, u, v, w, x); // $ExpectType { name: string; } & EventTarget & Node & Comment $.extend(t, u, v, w); // $ExpectType { name: string; } & EventTarget & Node $.extend(t, u, v); // $ExpectType { name: string; } & EventTarget $.extend(t, u); // $ExpectType any $.extend(t, u, v, w, x, y, z, a); } function get() { // $ExpectType jqXHR $.get('url', { myData: 'myData' }, (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.get('url', 'myData', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.get('url', { myData: 'myData' }, null, 'script'); // $ExpectType jqXHR $.get('url', 'myData', null, 'script'); // $ExpectType jqXHR $.get('url', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.get('url', null, 'script'); // $ExpectType jqXHR $.get('url', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.get('url', { myData: 'myData' }); // $ExpectType jqXHR $.get('url', 'myData'); // $ExpectType jqXHR $.get('url'); // $ExpectType jqXHR $.get({ url: 'url' }); // $ExpectType jqXHR $.get(); } function getJSON() { // $ExpectType jqXHR $.getJSON('url', { myVal1: 'myVal1' }, (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType jqXHR $.getJSON('url', 'myVal1', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType jqXHR $.getJSON('url', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType jqXHR $.getJSON('url', { myVal1: 'myVal1' }); // $ExpectType jqXHR $.getJSON('url', 'myVal1'); // $ExpectType jqXHR $.getJSON('url'); } function getScript() { // $ExpectType jqXHR $.getScript('url', (data, textStatus, jqXHR) => { // $ExpectType string | undefined data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }); } function globalEval() { // $ExpectType void $.globalEval('throw new Error();'); } function grep() { // $ExpectType string[] $.grep(['myVal1', 'myVal2'], (elementOfArray, indexInArray) => { // $ExpectType string elementOfArray; // $ExpectType number indexInArray; return true; }, true); // $ExpectType string[] $.grep(['myVal1', 'myVal2'], (elementOfArray, indexInArray) => { // $ExpectType string elementOfArray; // $ExpectType number indexInArray; return true; }); } function hasData() { // $ExpectType boolean $.hasData(new HTMLElement()); } function holdReady() { // $ExpectType void $.holdReady(true); } function htmlPrefilter() { // $ExpectType string $.htmlPrefilter(''); } function inArray() { // $ExpectType number $.inArray(1, [1, 2], 1); // $ExpectType number $.inArray(1, [1, 2]); } function isArray() { function type_guard(obj: object) { if ($.isArray(obj)) { // $ExpectType any[] obj; } } } function isEmptyObject() { function type_guard(obj: object) { if ($.isEmptyObject(obj)) { // $ExpectType {} obj; } } } function isFunction() { function type_guard(obj: object) { if ($.isFunction(obj)) { // $ExpectType Function obj; } } } function isNumeric() { function type_guard(obj: boolean) { if ($.isNumeric(obj)) { // $ExpectType (true & number) | (false & number) obj; } } } function isPlainObject() { function type_guard(obj: object) { if ($.isPlainObject(obj)) { // $ExpectType PlainObject obj; } } } function isWindow() { function type_guard(obj: object) { if ($.isWindow(obj)) { // $ExpectType Window obj; } } } function isXMLDoc() { // $ExpectType boolean $.isXMLDoc(new Node()); } function makeArray() { // $ExpectType number[] $.makeArray([1, 2]); } function map() { // $ExpectType number[] $.map([1, 2, 3], (elementOfArray, indexInArray) => { // $ExpectType number elementOfArray; // $ExpectType number indexInArray; return 200 + 10; }); // $ExpectType (false | 1)[] $.map({ myProp: true, name: 'Rogers', }, (propertyOfObject, key) => { // $ExpectType string | boolean propertyOfObject; // $ExpectType "myProp" | "name" key; switch (key) { case 'myProp': return 1; case 'name': return false; } }); } function merge() { // $ExpectType (string | number)[] $.merge([1, 2, 3], ['myVal1', 'myVal2']); } function noConflict() { // $ExpectType JQueryStatic $.noConflict(true); // $ExpectType JQueryStatic $.noConflict(); } function noop() { // $ExpectType undefined $.noop(); } function now() { // $ExpectType number $.now(); } function param() { // $ExpectType string $.param([true, 20], true); // $ExpectType string $.param({ myVal1: true, myVal2: 20 }, true); // $ExpectType string $.param($('input'), true); // $ExpectType string $.param([true, 20]); // $ExpectType string $.param({ myVal1: true, myVal2: 20 }); // $ExpectType string $.param($('input')); } function parseHTML() { // $ExpectType Node[] $.parseHTML('', document, true); // $ExpectType Node[] $.parseHTML('', null, true); // $ExpectType Node[] $.parseHTML('', undefined, true); // $ExpectType Node[] $.parseHTML('', document); // $ExpectType Node[] $.parseHTML('', null); // $ExpectType Node[] $.parseHTML('', undefined); // $ExpectType Node[] $.parseHTML('', false); // $ExpectType Node[] $.parseHTML(''); } function parseJSON() { // $ExpectType any $.parseJSON('{}'); } function parseXML() { // $ExpectType XMLDocument $.parseXML(''); } function post() { // $ExpectType jqXHR $.post('url', { myData: 'myData' }, (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.post('url', 'myData', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.post('url', { myData: 'myData' }, null, 'script'); // $ExpectType jqXHR $.post('url', 'myData', null, 'script'); // $ExpectType jqXHR $.post('url', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.post('url', null, 'script'); // $ExpectType jqXHR $.post('url', (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 'script'); // $ExpectType jqXHR $.post('url', { myData: 'myData' }); // $ExpectType jqXHR $.post('url', 'myData'); // $ExpectType jqXHR $.post('url'); // $ExpectType jqXHR $.post({ url: 'url' }); // $ExpectType jqXHR $.post(); } function proxy() { // $ExpectType Function $.proxy($.noop, {}, 1, 2); // $ExpectType Function $.proxy($.noop, {}); // $ExpectType Function $.proxy({ myFunc: $.noop }, 'myFunc', 1, 2); // $ExpectType Function $.proxy({ myFunc: $.noop }, 'myFunc'); } function queue() { // $ExpectType Queue $.queue(new HTMLElement(), 'myQueue', function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; }); // $ExpectType Queue $.queue(new HTMLElement(), 'myQueue', [function(next) { // $ExpectType HTMLElement this; // $ExpectType () => void next; }]); // $ExpectType Queue $.queue(new HTMLElement(), 'myQueue'); // $ExpectType Queue $.queue(new HTMLElement()); } function readyException() { jQuery.readyException = (error) => { console.error(error); }; } function removeData() { // $ExpectType void $.removeData(new HTMLElement(), 'test1'); // $ExpectType void $.removeData(new HTMLElement()); } function speed() { // $ExpectType EffectsOptions $.speed(5000, 'linear', function() { // $ExpectType HTMLElement this; }); // $ExpectType EffectsOptions $.speed(5000, 'linear'); // $ExpectType EffectsOptions $.speed(5000, function() { // $ExpectType HTMLElement this; }); // $ExpectType EffectsOptions $.speed(5000); // $ExpectType EffectsOptions $.speed(function() { // $ExpectType HTMLElement this; }); // $ExpectType EffectsOptions $.speed({ duration: 5000, easing: 'linear', complete() { // $ExpectType HTMLElement this; } }); // $ExpectType EffectsOptions $.speed(); } function trim() { // $ExpectType string $.trim('myStr'); } function type() { // $ExpectType "string" | "number" | "boolean" | "symbol" | "undefined" | "object" | "function" | "error" | "array" | "date" | "null" | "regexp" $.type({}); } function unique() { // $ExpectType HTMLElement[] $.unique([new HTMLElement()]); } function uniqueSort() { // $ExpectType HTMLElement[] $.uniqueSort([new HTMLElement()]); } function when() { interface I1 { kind: 'I1'; } interface I2 { kind: 'I2'; } interface I3 { kind: 'I3'; } interface I4 { kind: 'I4'; } interface I5 { kind: 'I5'; } interface I6 { kind: 'I6'; } interface I7 { kind: 'I7'; } interface I8 { kind: 'I8'; } interface I9 { kind: 'I9'; } function Promise3() { const t = $.ajax() as JQuery.jqXHR; const u = $.ajax() as JQuery.jqXHR; const v = $.ajax() as JQuery.jqXHR; // // 3 parameters // { // const w = $.when(t, u, v); // // w.then((a, b, c) => { // a[0]; // $ExpectType string // a[1]; // $ExpectType SuccessTextStatus // a[2]; // $ExpectType jqXHR // b[0]; // $ExpectType number // b[1]; // $ExpectType SuccessTextStatus // b[2]; // $ExpectType jqXHR // c[0]; // $ExpectType boolean // c[1]; // $ExpectType SuccessTextStatus // c[2]; // $ExpectType jqXHR // }, (a, b, c) => { // a[0]; // $ExpectType jqXHR // a[1]; // $ExpectType ErrorTextStatus // a[2]; // $ExpectType string // b[0]; // $ExpectType jqXHR // b[1]; // $ExpectType ErrorTextStatus // b[2]; // $ExpectType string // c[0]; // $ExpectType jqXHR // c[1]; // $ExpectType ErrorTextStatus // c[2]; // $ExpectType string // }, (a, b, c) => { // a; // $ExpectType never // b; // $ExpectType never // c; // $ExpectType never // }); // } // // // 2 parameters // { // const w = $.when(t, u); // // w.then((a, b) => { // a[0]; // $ExpectType string // a[1]; // $ExpectType SuccessTextStatus // a[2]; // $ExpectType jqXHR // b[0]; // $ExpectType number // b[1]; // $ExpectType SuccessTextStatus // b[2]; // $ExpectType jqXHR // }, (a, b) => { // a[0]; // $ExpectType jqXHR // a[1]; // $ExpectType ErrorTextStatus // a[2]; // $ExpectType string // b[0]; // $ExpectType jqXHR // b[1]; // $ExpectType ErrorTextStatus // b[2]; // $ExpectType string // }, (a, b) => { // a; // $ExpectType never // b; // $ExpectType never // }); // } // 1 parameter { const w = $.when(t); w.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType SuccessTextStatus c; // $ExpectType jqXHR }, (a, b, c) => { a; // $ExpectType jqXHR b; // $ExpectType ErrorTextStatus c; // $ExpectType string }, (a, b, c) => { a; // $ExpectType never b; // $ExpectType never c; // $ExpectType never }); } } function Promise2() { const t: JQuery.Promise2 = {} as any; const u: JQuery.Promise2 = {} as any; const v: JQuery.Promise2 = {} as any; // // 3 parameters // { // const w = $.when(t, u, v); // // w.then((a, b, c) => { // a[0]; // $ExpectType string // a[1]; // $ExpectType boolean // b[0]; // $ExpectType string // b[1]; // $ExpectType boolean // c[0]; // $ExpectType string // c[1]; // $ExpectType boolean // }, (a, b, c) => { // a[0]; // $ExpectType Error // a[1]; // $ExpectType any // b[0]; // $ExpectType Error // b[1]; // $ExpectType any // c[0]; // $ExpectType Error // c[1]; // $ExpectType any // }, (a, b, c) => { // a; // $ExpectType never // b; // $ExpectType never // c; // $ExpectType never // }); // } // // // 2 parameters // { // const w = $.when(t, u); // // w.then((a, b) => { // a[0]; // $ExpectType string // a[1]; // $ExpectType boolean // b[0]; // $ExpectType string // b[1]; // $ExpectType boolean // }, (a, b) => { // a[0]; // $ExpectType Error // a[1]; // $ExpectType any // b[0]; // $ExpectType Error // b[1]; // $ExpectType any // }, (a, b) => { // a; // $ExpectType never // b; // $ExpectType never // }); // } // 1 parameter { const w = $.when(t); w.then((a, b) => { a; // $ExpectType string b; // $ExpectType boolean }, (a, b) => { a; // $ExpectType Error b; // $ExpectType any }, (a, b) => { a; // $ExpectType never b; // $ExpectType never }); } } function Promise() { const p1: JQuery.Promise = {} as any; const p2: JQuery.Promise = {} as any; const p3: JQuery.Promise = {} as any; // 3 parameters { const w = $.when(p1, p2, p3); w.then((a, b, c) => { a; // $ExpectType I1 b; // $ExpectType I2 c; // $ExpectType I3 }, (a, b, c) => { a; // $ExpectType I2 b; // $ExpectType I3 c; // $ExpectType I4 }, (a, b, c) => { a; // $ExpectType never b; // $ExpectType never c; // $ExpectType never }); } // 2 parameters { const w = $.when(p1, p2); w.then((a, b) => { a; // $ExpectType I1 b; // $ExpectType I2 }, (a, b) => { a; // $ExpectType I2 b; // $ExpectType I3 }, (a, b) => { a; // $ExpectType never b; // $ExpectType never }); } // 1 parameter { const w = $.when(p1); w.then(a => { a; // $ExpectType I1 }, a => { a; // $ExpectType I2 }, a => { a; // $ExpectType never }); } } function Thenable() { const t1: JQuery.Thenable = {} as any; const t2: JQuery.Thenable = {} as any; const t3: JQuery.Thenable = {} as any; // 3 parameters { const w = $.when(t1, t2, t3); w.then((a, b, c) => { a; // $ExpectType I1 b; // $ExpectType I2 c; // $ExpectType I3 }, (a, b, c) => { a; // $ExpectType any b; // $ExpectType any c; // $ExpectType any }, (a, b, c) => { a; // $ExpectType never b; // $ExpectType never c; // $ExpectType never }); } // 2 parameters { const w = $.when(t1, t2); w.then((a, b) => { a; // $ExpectType I1 b; // $ExpectType I2 }, (a, b) => { a; // $ExpectType any b; // $ExpectType any }, (a, b) => { a; // $ExpectType never b; // $ExpectType never }); } // 1 parameter { const w = $.when(t1); w.then(a => { a; // $ExpectType I1 }, a => { a; // $ExpectType any }, a => { a; // $ExpectType never }); } } function value() { const w = $.when('myVal1'); w.then(a => { a; // $ExpectType string }); } function Zero() { const w = $.when(); w.then(a => { a; // $ExpectType never }, a => { a; // $ExpectType never }, a => { a; // $ExpectType never }); } // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/2725 function issue_2725() { function first() { return $.when('1'); } $.when().then(() => { return first(); }).then((value) => { value; // $ExpectType string }); } // https://github.com/DefinitelyTyped/DefinitelyTyped/issues/10159 function issue_10159() { interface One { result: number; } interface Two { Result: number; } interface Three { TheResult: number; } class AsyncRunner { Run(): void { const task1 = this.runTask1(); const task2 = this.runTask2(); const task3 = this.runTask3(); $.when(task1, task2, task3) .then((r1, r2, r3) => { r1; // $ExpectType One r2; // $ExpectType Two r3; // $ExpectType Three }); } runTask1() { let dfd = $.Deferred(); console.log('Task 1'); setTimeout(() => { dfd.resolve({ result: 1 }); }, Math.floor(400 + Math.random() * 2000)); return dfd.promise(); } runTask2() { let dfd = $.Deferred(); console.log('Task 2'); setTimeout(() => { dfd.resolve({ Result: 2 }); }, Math.floor(400 + Math.random() * 2000)); return dfd.promise(); } runTask3() { let dfd = $.Deferred(); console.log('Task 3'); setTimeout(() => { dfd.resolve({ TheResult: 3 }); }, Math.floor(400 + Math.random() * 2000)); return dfd.promise(); } } } } } function AjaxSettings() { $.ajax({ accepts: { mycustomtype: 'application/x-some-custom-type' }, async: true, beforeSend(jqXHR, settings) { // $ExpectType any this; // $ExpectType jqXHR jqXHR; // $ExpectType AjaxSettingsBase settings; }, cache: false, complete(jqXHR, textStatus) { // $ExpectType any this; // $ExpectType jqXHR jqXHR; // $ExpectType TextStatus textStatus; }, contents: { mycustomtype: /mycustomtype/ }, contentType: 'application/x-some-custom-type', converters: { 'text mycustomtype': true, 'mycustomtype json': (result) => { // $ExpectType any result; return result; } }, crossDomain: false, data: { myData: 'myData' }, dataFilter(data, type) { // $ExpectType string data; // $ExpectType string type; return 'filtered'; }, dataType: 'mycustomtype', error(jqXHR, textStatus, errorThrown) { // $ExpectType any this; // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }, global: true, headers: { 'X-Requested-With': 'XMLHttpRequest' }, ifModified: false, isLocal: true, jsonp: 'callback', jsonpCallback: 'callback', method: 'PUT', mimeType: 'mimeType', password: 'hunter2', processData: false, scriptCharset: 'scriptCharset', statusCode: { 200(data, textStatus, jqXHR) { // $ExpectType any this; // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, 404(jqXHR, textStatus, errorThrown) { // $ExpectType any this; // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; } }, success(data, textStatus, jqXHR) { // $ExpectType any this; // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, timeout: 10, traditional: true, username: 'username', xhr() { return new XMLHttpRequest(); }, xhrFields: { withCredentials: true } }); $.ajax({ beforeSend(jqXHR, settings) { // $ExpectType any this; // $ExpectType jqXHR jqXHR; // $ExpectType AjaxSettingsBase settings; return false; }, complete: [function(jqXHR, textStatus) { // $ExpectType any this; // $ExpectType jqXHR jqXHR; // $ExpectType TextStatus textStatus; }], contentType: false, data: 'myData', error: [function(jqXHR, textStatus, errorThrown) { // $ExpectType any this; // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }], jsonp: false, jsonpCallback() { // $ExpectType any this; return 'callback'; }, success: [function(data, textStatus, jqXHR) { // $ExpectType any this; // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }] }); } function Callbacks() { function add() { const callbacks = $.Callbacks(); // $ExpectType Callbacks callbacks.add(() => { }, [() => { }], () => { }); // $ExpectType Callbacks callbacks.add(() => { }, [() => { }]); // $ExpectType Callbacks callbacks.add(() => { }, () => { }); // $ExpectType Callbacks callbacks.add(() => { }); // $ExpectType Callbacks callbacks.add([() => { }]); } function disable() { // $ExpectType Callbacks $.Callbacks().disable(); } function disabled() { // $ExpectType boolean $.Callbacks().disabled(); } function empty() { // $ExpectType Callbacks $.Callbacks().empty(); } function fire() { // $ExpectType Callbacks $.Callbacks().fire(1); // $ExpectType Callbacks $.Callbacks().fire(); } function fireWith() { // $ExpectType Callbacks $.Callbacks().fireWith(window, [1]); // $ExpectType Callbacks $.Callbacks().fireWith(window); } function fired() { // $ExpectType boolean $.Callbacks().fired(); } function has() { // $ExpectType boolean $.Callbacks().has(() => { }); // $ExpectType boolean $.Callbacks().has(); } function lock() { // $ExpectType Callbacks $.Callbacks().lock(); } function locked() { // $ExpectType boolean $.Callbacks().locked(); } function remove() { // $ExpectType Callbacks $.Callbacks().remove(() => { }, () => { }); } } function EffectsOptions() { $('p').show({ always(animation, jumpToEnd) { // $ExpectType HTMLElement this; // $ExpectType Promise animation; // $ExpectType boolean jumpToEnd; }, complete() { // $ExpectType HTMLElement this; }, done(animation, jumpToEnd) { // $ExpectType HTMLElement this; // $ExpectType Promise animation; // $ExpectType boolean jumpToEnd; }, duration: 5000, easing: 'linear', fail(animation, jumpToEnd) { // $ExpectType HTMLElement this; // $ExpectType Promise animation; // $ExpectType boolean jumpToEnd; }, progress(animation, progress, remainingMs) { // $ExpectType HTMLElement this; // $ExpectType Promise animation; // $ExpectType number progress; // $ExpectType number remainingMs; }, queue: true, specialEasing: { width: 'linear', height: 'easeOutBounce' }, start(animation) { // $ExpectType HTMLElement this; // $ExpectType Promise animation; }, step(now, tween) { // $ExpectType HTMLElement this; // $ExpectType number now; // $ExpectType Tween tween; } }); } function _Event() { function call_signature() { // $ExpectType Event & Coordinates $.Event('keydown', $('p').offset()); // $ExpectType Event & { type: string; } $.Event({ type: 'keydown' }); } function constructor() { // $ExpectType Event & Coordinates new $.Event('keydown', $('p').offset()); // $ExpectType Event & { type: string; } new $.Event({ type: 'keydown' }); } } function jqXHR() { function always() { // $ExpectType jqXHR $.ajax('/echo/json').always((data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }, [(data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }], (data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }); // $ExpectType jqXHR $.ajax('/echo/json').always((data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }, [(data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }]); // $ExpectType jqXHR $.ajax('/echo/json').always([(data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }], (data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }); // $ExpectType jqXHR $.ajax('/echo/json').always((data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }); // $ExpectType jqXHR $.ajax('/echo/json').always([(data_jqXHR, textStatus, jqXHR_errorThrown) => { // $ExpectType any data_jqXHR; // $ExpectType TextStatus textStatus; // $ExpectType string | jqXHR jqXHR_errorThrown; }]); } function done() { // $ExpectType jqXHR $.ajax('/echo/json').done((data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, [(data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }], (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType jqXHR $.ajax('/echo/json').done((data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }, [(data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }]); // $ExpectType jqXHR $.ajax('/echo/json').done([(data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }], (data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType jqXHR $.ajax('/echo/json').done((data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }); // $ExpectType jqXHR $.ajax('/echo/json').done([(data, textStatus, jqXHR) => { // $ExpectType any data; // $ExpectType SuccessTextStatus textStatus; // $ExpectType jqXHR jqXHR; }]); } function fail() { // $ExpectType jqXHR $.ajax('/echo/json').fail((jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }, [(jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }], (jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }); // $ExpectType jqXHR $.ajax('/echo/json').fail((jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }, [(jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }]); // $ExpectType jqXHR $.ajax('/echo/json').fail([(jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }], (jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }); // $ExpectType jqXHR $.ajax('/echo/json').fail((jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }); // $ExpectType jqXHR $.ajax('/echo/json').fail([(jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }]); } function _catch() { // $ExpectType Promise3 $.ajax('/echo').catch((jqXHR, textStatus, errorThrown) => { // $ExpectType jqXHR jqXHR; // $ExpectType ErrorTextStatus textStatus; // $ExpectType string errorThrown; }); } } function Promise3() { interface I1 { kind: 'I1'; } interface I2 { kind: 'I2'; } interface I3 { kind: 'I3'; } interface I4 { kind: 'I4'; } interface I5 { kind: 'I5'; } interface I6 { kind: 'I6'; } interface I7 { kind: 'I7'; } interface I8 { kind: 'I8'; } interface I9 { kind: 'I9'; } const p: JQuery.Promise3 = {} as any; const p1: JQuery.Promise3 = {} as any; const p2: JQuery.Promise3 = {} as any; const p3: JQuery.Promise3 = {} as any; const t1: JQuery.Thenable = {} as any; const t2: JQuery.Thenable = {} as any; const t3: JQuery.Thenable = {} as any; function then() { p.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }, (a, b, c) => { a; // $ExpectType number b; // $ExpectType boolean c; // $ExpectType never }); p.then(null, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }, (a, b, c) => { a; // $ExpectType number b; // $ExpectType boolean c; // $ExpectType never }); p.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, null, (a, b, c) => { a; // $ExpectType number b; // $ExpectType boolean c; // $ExpectType never }); p.then(null, null, (a, b, c) => { a; // $ExpectType number b; // $ExpectType boolean c; // $ExpectType never }); p.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }, null); p.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }); p.then(null, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }, null); p.then(null, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }); p.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, null, null); p.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, null); p.then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }); function doneFilter() { p.then(() => { return 1; }).then((a) => { a; // $ExpectType number }); p.then(() => { return $.ready; }).then((a) => { a; // $ExpectType JQueryStatic }); p.then(() => { return p; }).then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }, (a, b, c) => { a; // $ExpectType number b; // $ExpectType boolean c; // $ExpectType never }); } function failFilter() { p.then(null, () => { return 1; }).then((a) => { a; // $ExpectType number }); p.then(null, () => { return $.ready; }).then((a) => { a; // $ExpectType JQueryStatic }); p.then(null, () => { return p; }).then((a, b, c) => { a; // $ExpectType string b; // $ExpectType JQuery c; // $ExpectType any }, (a, b, c) => { a; // $ExpectType Error b; // $ExpectType string c; // $ExpectType Function }, (a, b, c) => { a; // $ExpectType number b; // $ExpectType boolean c; // $ExpectType never }); } function doneFilter_failFilter() { // (value, value) { const q = p.then(() => { return 1; }, () => { return 1; }); q.then((a) => { a; // $ExpectType number }, (a) => { a; // $ExpectType never }, (a, b, c) => { a; // $ExpectType never b; // $ExpectType never c; // $ExpectType never }); } // (Thenable, Thenable) { const q = p.then(() => { return t1; }, () => { return t2; }); q.then((a) => { a; // $ExpectType I1 | I2 }, (a) => { a; // $ExpectType never }, (a, b, c) => { a; // $ExpectType never b; // $ExpectType never c; // $ExpectType never }); } // (Promise3, Promise3) { const q = p.then(() => { return p1; }, () => { return p2; }); q.then((a, b, c) => { a; // $ExpectType I1 | I2 b; // $ExpectType I4 | I5 c; // $ExpectType I7 | I8 }, (a, b, c) => { a; // $ExpectType I2 | I3 b; // $ExpectType I5 | I6 c; // $ExpectType I8 | I9 }, (a, b, c) => { a; // $ExpectType I3 | I4 b; // $ExpectType I6 | I7 c; // $ExpectType I1 | I9 }); } // (value, Thenable) { const q = p.then(() => { return 1; }, () => { return t1; }); q.then((a) => { a; // $ExpectType number | I1 }, (a) => { a; // never }, (a, b, c) => { a; // $ExpectType never b; // $ExpectType never c; // $ExpectType never }); } // (Thenable, value) { const q = p.then(() => { return t1; }, () => { return 1; }); q.then((a) => { a; // $ExpectType number | I1 }, (a) => { a; // never }, (a, b, c) => { a; // $ExpectType never b; // $ExpectType never c; // $ExpectType never }); } // (value, Promise3) { const q = p.then(() => { return 1; }, () => { return p1; }); q.then((a, b, c) => { a; // $ExpectType number | I1 b; // $ExpectType I4 c; // $ExpectType I7 }, (a, b, c) => { a; // $ExpectType I2 b; // $ExpectType I5 c; // $ExpectType I8 }, (a, b, c) => { a; // $ExpectType I3 b; // $ExpectType I6 c; // $ExpectType I9 }); } // (Promise3, value) { const q = p.then(() => { return p1; }, () => { return 1; }); q.then((a, b, c) => { a; // $ExpectType number | I1 b; // $ExpectType I4 c; // $ExpectType I7 }, (a, b, c) => { a; // $ExpectType I2 b; // $ExpectType I5 c; // $ExpectType I8 }, (a, b, c) => { a; // $ExpectType I3 b; // $ExpectType I6 c; // $ExpectType I9 }); } // (Thenable, Promise3) { const q = p.then(() => { return t1; }, () => { return p2; }); q.then((a, b, c) => { a; // $ExpectType I1 | I2 b; // $ExpectType I5 c; // $ExpectType I8 }, (a, b, c) => { a; // $ExpectType I3 b; // $ExpectType I6 c; // $ExpectType I9 }, (a, b, c) => { a; // $ExpectType I4 b; // $ExpectType I7 c; // $ExpectType I1 }); } // (Promise3, Thenable) { const q = p.then(() => { return p1; }, () => { return t2; }); q.then((a, b, c) => { a; // $ExpectType I1 | I2 b; // $ExpectType I4 c; // $ExpectType I7 }, (a, b, c) => { a; // $ExpectType I2 b; // $ExpectType I5 c; // $ExpectType I8 }, (a, b, c) => { a; // $ExpectType I3 b; // $ExpectType I6 c; // $ExpectType I9 }); } } } function _catch() { // $ExpectType Promise3 $.ajax('/echo/json').catch(() => { return 1; }); // $ExpectType Promise3 $.ajax('/echo/json').catch(() => { return t1; }); // $ExpectType Promise3, never, SuccessTextStatus, ErrorTextStatus, never, jqXHR, string, never> $.ajax('/echo/json').catch(() => { return $.ajax('/echo/json'); }); } } function Promise2(p: JQuery.Promise2) { function then() { p.then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }, (a, b) => { a; // $ExpectType number b; // $ExpectType boolean }); p.then(null, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }, (a, b) => { a; // $ExpectType number b; // $ExpectType boolean }); p.then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, null, (a, b) => { a; // $ExpectType number b; // $ExpectType boolean }); p.then(null, null, (a, b) => { a; // $ExpectType number b; // $ExpectType boolean }); p.then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }, null); p.then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }); p.then(null, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }, null); p.then(null, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }); p.then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, null, null); p.then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, null); p.then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }); function doneFilter() { p.then(() => { return 1; }).then((a) => { a; // $ExpectType number }); p.then(() => { return $.ready; }).then((a) => { a; // $ExpectType JQueryStatic }); p.then(() => { return p; }).then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }, (a, b) => { a; // $ExpectType number b; // $ExpectType boolean }); } function failFilter() { p.then(null, () => { return 1; }).then((a) => { a; // $ExpectType number }); p.then(null, () => { return $.ready; }).then((a) => { a; // $ExpectType JQueryStatic }); p.then(null, () => { return p; }).then((a, b) => { a; // $ExpectType string b; // $ExpectType JQuery }, (a, b) => { a; // $ExpectType Error b; // $ExpectType string }, (a, b) => { a; // $ExpectType number b; // $ExpectType boolean }); } } } function _Promise(p: JQuery.Promise) { function then() { p.then((a) => { a; // $ExpectType string }, (a) => { a; // $ExpectType Error }, (a) => { a; // $ExpectType number }); p.then(null, (a) => { a; // $ExpectType Error }, (a) => { a; // $ExpectType number }); p.then((a) => { a; // $ExpectType string }, null, (a) => { a; // $ExpectType number }); p.then(null, null, (a) => { a; // $ExpectType number }); p.then((a) => { a; // $ExpectType string }, (a) => { a; // $ExpectType Error }, null); p.then((a) => { a; // $ExpectType string }, (a) => { a; // $ExpectType Error }); p.then(null, (a) => { a; // $ExpectType Error }, null); p.then(null, (a) => { a; // $ExpectType Error }); p.then((a) => { a; // $ExpectType string }, null, null); p.then((a) => { a; // $ExpectType string }, null); p.then((a) => { a; // $ExpectType string }); function doneFilter() { p.then(() => { return 1; }).then((a) => { a; // $ExpectType number }); p.then(() => { return $.ready; }).then((a) => { a; // $ExpectType JQueryStatic }); p.then(() => { return p; }).then((a) => { a; // $ExpectType string }, (a) => { a; // $ExpectType Error }, (a) => { a; // $ExpectType number }); } function failFilter() { p.then(null, () => { return 1; }).then((a) => { a; // $ExpectType number }); p.then(null, () => { return $.ready; }).then((a) => { a; // $ExpectType JQueryStatic }); p.then(null, () => { return p; }).then((a) => { a; // $ExpectType string }, (a) => { a; // $ExpectType Error }, (a) => { a; // $ExpectType number }); } } }