Merge pull request #17625 from leonard-thieu/revert-weak-types-workaround

[tough-cookie][electron-settings][semantic-ui-*] Fix weak type workaround
This commit is contained in:
Ryan Cavanaugh
2017-07-13 19:08:21 -07:00
committed by GitHub
43 changed files with 2210 additions and 1103 deletions
+31 -44
View File
@@ -2,7 +2,6 @@
// Project: https://github.com/nathanbuchar/electron-settings
// Definitions by: Leonard Thieu <https://github.com/leonard-thieu>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
/// <reference types="node" />
@@ -20,7 +19,7 @@ declare class Settings extends EventEmitter {
*
* @throws if options is not an object.
*/
configure(options: ElectronSettings.Options.Param): void;
configure(options: ElectronSettings.Options): void;
/**
* Globally configures default settings.
@@ -79,14 +78,14 @@ declare class Settings extends EventEmitter {
* @throws if options is not an object.
* @see setSync
*/
set(keyPath: string, value: any, options?: ElectronSettings.Options.Param): Promise<void>;
set(keyPath: string, value: any, options?: ElectronSettings.Options): Promise<void>;
/**
* The synchronous version of set().
*
* @see set
*/
setSync(keyPath: string, value: any, options?: ElectronSettings.Options.Param): void;
setSync(keyPath: string, value: any, options?: ElectronSettings.Options): void;
/**
* Deletes the key and value at the chosen key path.
@@ -97,14 +96,14 @@ declare class Settings extends EventEmitter {
* @throws if options is not an object.
* @see deleteSync
*/
delete(keyPath: string, options?: ElectronSettings.Options.Param): Promise<void>;
delete(keyPath: string, options?: ElectronSettings.Options): Promise<void>;
/**
* The synchronous version of delete().
*
* @see delete
*/
deleteSync(keyPath: string, options?: ElectronSettings.Options.Param): void;
deleteSync(keyPath: string, options?: ElectronSettings.Options): void;
/**
* Clears the entire settings object.
@@ -113,14 +112,14 @@ declare class Settings extends EventEmitter {
* @throws if options is not an object.
* @see clearSync
*/
clear(options?: ElectronSettings.Options.Param): Promise<void>;
clear(options?: ElectronSettings.Options): Promise<void>;
/**
* The synchronous version of clear().
*
* @see clear
*/
clearSync(options?: ElectronSettings.Options.Param): void;
clearSync(options?: ElectronSettings.Options): void;
/**
* Applies defaults to the current settings object (deep).
@@ -133,14 +132,14 @@ declare class Settings extends EventEmitter {
* @see defaults
* @see applyDefaultsSync
*/
applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions.Param): Promise<void>;
applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions): Promise<void>;
/**
* The synchronous version of applyDefaults().
*
* @see applyDefaults
*/
applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions.Param): void;
applyDefaultsSync(options?: ElectronSettings.ApplyDefaultsOptions): void;
/**
* Resets all settings to defaults.
@@ -151,14 +150,14 @@ declare class Settings extends EventEmitter {
* @see defaults
* @see resetToDefaultsSync
*/
resetToDefaults(options?: ElectronSettings.Options.Param): Promise<void>;
resetToDefaults(options?: ElectronSettings.Options): Promise<void>;
/**
* The synchronous version of resetToDefaults().
*
* @see resetToDefaults
*/
resetToDefaultsSync(options?: ElectronSettings.Options.Param): void;
resetToDefaultsSync(options?: ElectronSettings.Options): void;
/**
* Observes the chosen key path for changes and calls the handler if the value changes.
@@ -209,40 +208,28 @@ declare namespace ElectronSettings {
dispose(): void;
}
interface Options extends Pick<Options._Impl, keyof Options._Impl> { }
namespace Options {
type Param = Options | object;
interface _Impl {
/**
* Whether electron-settings should create a tmp file during save to ensure data-write consistency.
*
* @default true
*/
atomicSaving: boolean;
/**
* Prettify the JSON output.
*
* @default false
*/
prettify: boolean;
}
interface Options {
/**
* Whether electron-settings should create a tmp file during save to ensure data-write consistency.
*
* @default true
*/
atomicSaving?: boolean;
/**
* Prettify the JSON output.
*
* @default false
*/
prettify?: boolean;
}
interface ApplyDefaultsOptions extends Pick<ApplyDefaultsOptions._Impl, keyof ApplyDefaultsOptions._Impl> { }
namespace ApplyDefaultsOptions {
type Param = ApplyDefaultsOptions | object;
interface _Impl extends Options._Impl {
/**
* Overwrite pre-existing settings with their respective default values.
*
* @default false
*/
overwrite: boolean;
}
interface ApplyDefaultsOptions extends Options {
/**
* Overwrite pre-existing settings with their respective default values.
*
* @default false
*/
overwrite?: boolean;
}
interface ChangeEvent {
+1
View File
@@ -4,6 +4,7 @@
"lib": [
"es6"
],
"target": "es2015",
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
+41 -12
View File
@@ -27,19 +27,41 @@ declare namespace SemanticUI {
*/
(behavior: 'toggle', index: number): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof AccordionSettings>(behavior: 'setting', name: K, value?: undefined): AccordionSettings[K];
<K extends keyof AccordionSettings>(behavior: 'setting', name: K, value: AccordionSettings[K]): JQuery;
(behavior: 'setting', value: AccordionSettings.Param): JQuery;
(settings?: AccordionSettings.Param): JQuery;
<K extends keyof AccordionSettings>(behavior: 'setting', name: K, value?: undefined): AccordionSettings._Impl[K];
<K extends keyof AccordionSettings>(behavior: 'setting', name: K, value: AccordionSettings._Impl[K]): JQuery;
(behavior: 'setting', value: AccordionSettings): JQuery;
(settings?: AccordionSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/accordion.html#/settings}
*/
interface AccordionSettings extends Pick<AccordionSettings._Impl, keyof AccordionSettings._Impl> { }
type AccordionSettings = AccordionSettings.Param;
namespace AccordionSettings {
type Param = AccordionSettings | object;
type Param = (Pick<_Impl, 'exclusive'> |
Pick<_Impl, 'on'> |
Pick<_Impl, 'animateChildren'> |
Pick<_Impl, 'closeNested'> |
Pick<_Impl, 'collapsible'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'easing'> |
Pick<_Impl, 'observeChanges'> |
Pick<_Impl, 'onOpening'> |
Pick<_Impl, 'onOpen'> |
Pick<_Impl, 'onClosing'> |
Pick<_Impl, 'onClose'> |
Pick<_Impl, 'onChange'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Behavior
@@ -181,10 +203,14 @@ declare namespace SemanticUI {
}
namespace Accordion {
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'accordion'> |
Pick<_Impl, 'title'> |
Pick<_Impl, 'trigger'> |
Pick<_Impl, 'content'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -206,10 +232,12 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'animating'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -223,10 +251,11 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -9,15 +9,16 @@ function test_static() {
function test_accordion() {
const selector = '.ui.accordion';
$(selector).accordion('refresh') === $();
$(selector).accordion('open', 3) === $();
$(selector).accordion('close others') === $();
$(selector).accordion('close', 10) === $();
$(selector).accordion('toggle', 5) === $();
$(selector).accordion('destroy') === $();
$(selector).accordion('setting', 'debug', undefined) === false;
$(selector).accordion('setting', 'debug') === false;
$(selector).accordion('setting', 'debug', true) === $();
$(selector).accordion('refresh'); // $ExpectType JQuery<HTMLElement>
$(selector).accordion('open', 3); // $ExpectType JQuery<HTMLElement>
$(selector).accordion('close others'); // $ExpectType JQuery<HTMLElement>
$(selector).accordion('close', 10); // $ExpectType JQuery<HTMLElement>
$(selector).accordion('toggle', 5); // $ExpectType JQuery<HTMLElement>
$(selector).accordion('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).accordion('setting', 'debug', undefined); // $ExpectType boolean
$(selector).accordion('setting', 'debug'); // $ExpectType boolean
$(selector).accordion('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).accordion('setting', {
namespace: 'namespace',
name: 'name',
@@ -25,7 +26,8 @@ function test_accordion() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).accordion({
exclusive: true,
on: 'on',
@@ -36,19 +38,19 @@ function test_accordion() {
easing: 'easeInOutQuint',
observeChanges: true,
onOpening() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onOpen() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onClosing() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onClose() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onChange() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
selector: {
accordion: 'accordion',
@@ -63,12 +65,16 @@ function test_accordion() {
error: {
method: 'method'
}
}) === $();
$(selector).accordion() === $();
});
$(selector).accordion(); // $ExpectType JQuery<HTMLElement>
$(selector).accordion('foo'); // $ExpectError
$(selector).accordion({ foo: 'bar' }); // $ExpectError
}
import accordion = require('semantic-ui-accordion');
function test_module() {
accordion; // $ExpectType Accordion
$.fn.accordion = accordion;
}
+92 -16
View File
@@ -98,18 +98,63 @@ declare namespace SemanticUI {
* Removes API settings from the page and all events
*/
(behavior: 'destroy'): JQuery;
<K extends keyof ApiSettings>(behavior: 'setting', name: K, value?: undefined): ApiSettings[K];
<K extends keyof ApiSettings>(behavior: 'setting', name: K, value: ApiSettings[K]): JQuery;
(behavior: 'setting', value: ApiSettings | object): JQuery;
(settings?: ApiSettings | object): JQuery;
<K extends keyof ApiSettings>(behavior: 'setting', name: K, value?: undefined): ApiSettings._Impl[K];
<K extends keyof ApiSettings>(behavior: 'setting', name: K, value: ApiSettings._Impl[K]): JQuery;
(behavior: 'setting', value: ApiSettings): JQuery;
(settings?: ApiSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/behaviors/api.html#/settings}
*/
interface ApiSettings extends Pick<ApiSettings._Impl, keyof ApiSettings._Impl> { }
type ApiSettings = ApiSettings.Param;
namespace ApiSettings {
type Param = (Pick<_Impl, 'on'> |
Pick<_Impl, 'cache'> |
Pick<_Impl, 'stateContext'> |
Pick<_Impl, 'encodeParameters'> |
Pick<_Impl, 'defaultData'> |
Pick<_Impl, 'serializeForm'> |
Pick<_Impl, 'throttle'> |
Pick<_Impl, 'throttleFirstRequest'> |
Pick<_Impl, 'interruptRequests'> |
Pick<_Impl, 'loadingDuration'> |
Pick<_Impl, 'hideError'> |
Pick<_Impl, 'errorDuration'> |
Pick<_Impl, 'action'> |
Pick<_Impl, 'url'> |
Pick<_Impl, 'urlData'> |
Pick<_Impl, 'response'> |
Pick<_Impl, 'responseAsync'> |
Pick<_Impl, 'mockResponse'> |
Pick<_Impl, 'mockResponseAsync'> |
Pick<_Impl, 'method'> |
Pick<_Impl, 'dataType'> |
Pick<_Impl, 'data'> |
Pick<_Impl, 'beforeSend'> |
Pick<_Impl, 'beforeXHR'> |
Pick<_Impl, 'onRequest'> |
Pick<_Impl, 'onResponse'> |
Pick<_Impl, 'successTest'> |
Pick<_Impl, 'onSuccess'> |
Pick<_Impl, 'onComplete'> |
Pick<_Impl, 'onFailure'> |
Pick<_Impl, 'onError'> |
Pick<_Impl, 'onAbort'> |
Pick<_Impl, 'regExp'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Behavior
@@ -246,11 +291,11 @@ declare namespace SemanticUI {
/**
* Allows modifying XHR object for request
*/
beforeXHR(xhrObject: JQueryXHR): any;
beforeXHR(xhrObject: JQuery.jqXHR): any;
/**
* Callback that occurs when request is made. Receives both the API success promise and the XHR request promise.
*/
onRequest(promise: JQueryDeferred<any>, xhr: JQueryXHR): void;
onRequest(promise: JQuery.Deferred<any>, xhr: JQuery.jqXHR): void;
/**
* Allows modifying the server's response before parsed by other callbacks to determine API event success
*/
@@ -264,11 +309,11 @@ declare namespace SemanticUI {
/**
* Callback after successful response, JSON response must pass successTest
*/
onSuccess(response: any, element: JQuery, xhr: JQueryXHR): void;
onSuccess(response: any, element: JQuery, xhr: JQuery.jqXHR): void;
/**
* Callback on request complete regardless of conditions
*/
onComplete(response: any, element: JQuery, xhr: JQueryXHR): void;
onComplete(response: any, element: JQuery, xhr: JQuery.jqXHR): void;
/**
* Callback on failed response, or JSON response that fails successTest
*/
@@ -276,11 +321,11 @@ declare namespace SemanticUI {
/**
* Callback on server error from returned status code, or XHR failure.
*/
onError(errorMessage: string, element: JQuery, xhr: JQueryXHR): void;
onError(errorMessage: string, element: JQuery, xhr: JQuery.jqXHR): void;
/**
* Callback on abort caused by user clicking a link or manually cancelling request.
*/
onAbort(errorMessage: string, element: JQuery, xhr: JQueryXHR): void;
onAbort(errorMessage: string, element: JQuery, xhr: JQuery.jqXHR): void;
// endregion
@@ -352,9 +397,13 @@ declare namespace SemanticUI {
}
namespace Api {
interface RegExpSettings extends Pick<RegExpSettings._Impl, keyof RegExpSettings._Impl> { }
type RegExpSettings = RegExpSettings.Param;
namespace RegExpSettings {
type Param = (Pick<_Impl, 'required'> |
Pick<_Impl, 'optional'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default /\{\$*[A-z0-9]+\}/g
@@ -367,9 +416,13 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = (Pick<_Impl, 'disabled'> |
Pick<_Impl, 'form'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default '.disabled'
@@ -382,9 +435,13 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = (Pick<_Impl, 'loading'> |
Pick<_Impl, 'error'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 'loading'
@@ -397,9 +454,13 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = (Pick<_Impl, 'action'> |
Pick<_Impl, 'url'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 'action'
@@ -412,9 +473,24 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = (Pick<_Impl, 'beforeSend'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'exitConditions'> |
Pick<_Impl, 'JSONParse'> |
Pick<_Impl, 'legacyParameters'> |
Pick<_Impl, 'missingAction'> |
Pick<_Impl, 'missingSerialize'> |
Pick<_Impl, 'missingURL'> |
Pick<_Impl, 'noReturnedValue'> |
Pick<_Impl, 'parseError'> |
Pick<_Impl, 'requiredParameter'> |
Pick<_Impl, 'statusMessage'> |
Pick<_Impl, 'timeout'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 'The before send function has aborted the request'
+40 -32
View File
@@ -1,5 +1,5 @@
function test_api_static() {
$.api.settings.className.error = 'error';
$.api.settings.className!.error = 'error';
$.api.settings.namespace = 'namespace';
$.api.settings.name = 'name';
$.api.settings.silent = false;
@@ -17,10 +17,11 @@ function test_api_static() {
function test_api() {
const selector = '.ui.api';
$(selector).api('destroy') === $();
$(selector).api('setting', 'debug', undefined) === false;
$(selector).api('setting', 'debug') === false;
$(selector).api('setting', 'debug', true) === $();
$(selector).api('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).api('setting', 'debug', undefined); // $ExpectType boolean
$(selector).api('setting', 'debug'); // $ExpectType boolean
$(selector).api('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).api('setting', {
namespace: 'namespace',
name: 'name',
@@ -28,7 +29,8 @@ function test_api() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).api({
on: 'on',
cache: true,
@@ -47,56 +49,58 @@ function test_api() {
urlData: false,
response: false,
responseAsync(settings, callback) {
settings === ({} as SemanticUI.ApiSettings);
callback === ((response: any) => { });
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
mockResponse: false,
mockResponseAsync(settings, callback) {
settings === ({} as SemanticUI.ApiSettings);
callback === ((response: any) => { });
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
method: 'post',
dataType: 'xml',
data: {},
beforeSend(settings) {
settings === ({} as SemanticUI.ApiSettings);
settings; // $ExpectType Param
},
beforeXHR(xhrObject) {
xhrObject === ({} as JQueryXHR);
xhrObject; // $ExpectType jqXHR<any>
},
onRequest(promise, xhr) {
promise === ({} as JQueryDeferred<any>);
xhr === ({} as JQueryXHR);
promise; // $ExpectType Deferred<any, any, any>
xhr; // $ExpectType jqXHR<any>
},
onResponse(response) {
response === ({} as any);
response; // $ExpectType any
},
successTest(response) {
return response === ({} as any);
response; // $ExpectType any
return false;
},
onSuccess(response, element, xhr) {
response === ({} as any);
element === $();
xhr === ({} as JQueryXHR);
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onComplete(response, element, xhr) {
response === ({} as any);
element === $();
xhr === ({} as JQueryXHR);
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onFailure(response, element) {
response === ({} as any);
element === $();
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
},
onError(errorMessage, element, xhr) {
errorMessage === '';
element === $();
xhr === ({} as JQueryXHR);
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onAbort(errorMessage, element, xhr) {
errorMessage === '';
element === $();
xhr === ({} as JQueryXHR);
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
regExp: {
required: /{\$*[A-z0-9]+}/g,
@@ -129,12 +133,16 @@ function test_api() {
statusMessage: 'statusMessage',
timeout: 'timeout'
}
}) === $();
$(selector).api() === $();
});
$(selector).api(); // $ExpectType JQuery<HTMLElement>
$(selector).api('foo'); // $ExpectError
$(selector).api({ foo: 'bar' }); // $ExpectError
}
import api = require('semantic-ui-api');
function test_module() {
api; // $ExpectType Api
$.fn.api = api;
}
+56 -25
View File
@@ -95,19 +95,43 @@ declare namespace SemanticUI {
*/
(behavior: 'can uncheck'): boolean;
(behavior: 'destroy'): JQuery;
<K extends keyof CheckboxSettings>(behavior: 'setting', name: K, value?: undefined): CheckboxSettings[K];
<K extends keyof CheckboxSettings>(behavior: 'setting', name: K, value: CheckboxSettings[K]): JQuery;
(behavior: 'setting', value: CheckboxSettings.Param): JQuery;
(settings?: CheckboxSettings.Param): JQuery;
<K extends keyof CheckboxSettings>(behavior: 'setting', name: K, value?: undefined): CheckboxSettings._Impl[K];
<K extends keyof CheckboxSettings>(behavior: 'setting', name: K, value: CheckboxSettings._Impl[K]): JQuery;
(behavior: 'setting', value: CheckboxSettings): JQuery;
(settings?: CheckboxSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/checkbox.html#/settings}
*/
interface CheckboxSettings extends Pick<CheckboxSettings._Impl, keyof CheckboxSettings._Impl> { }
type CheckboxSettings = CheckboxSettings.Param;
namespace CheckboxSettings {
type Param = CheckboxSettings | object;
type Param = (Pick<_Impl, 'uncheckable'> |
Pick<_Impl, 'fireOnInit'> |
Pick<_Impl, 'onChange'> |
Pick<_Impl, 'onChecked'> |
Pick<_Impl, 'onIndeterminate'> |
Pick<_Impl, 'onDeterminate'> |
Pick<_Impl, 'onUnchecked'> |
Pick<_Impl, 'beforeChecked'> |
Pick<_Impl, 'beforeIndeterminate'> |
Pick<_Impl, 'beforeDeterminate'> |
Pick<_Impl, 'beforeUnchecked'> |
Pick<_Impl, 'onEnable'> |
Pick<_Impl, 'onDisable'> |
Pick<_Impl, 'onEnabled'> |
Pick<_Impl, 'onDisabled'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Behavior
@@ -132,59 +156,59 @@ declare namespace SemanticUI {
/**
* Callback after a checkbox is either checked or unchecked.
*/
onChange(this: HTMLElement): void;
onChange(this: HTMLInputElement): void;
/**
* Callback after a checkbox is checked.
*/
onChecked(this: HTMLElement): void;
onChecked(this: HTMLInputElement): void;
/**
* Callback after a checkbox is set to undeterminate.
*/
onIndeterminate(this: HTMLElement): void;
onIndeterminate(this: HTMLInputElement): void;
/**
* Callback after a checkbox is set to determinate.
*/
onDeterminate(this: HTMLElement): void;
onDeterminate(this: HTMLInputElement): void;
/**
* Callback after a checkbox is unchecked.
*/
onUnchecked(this: HTMLElement): void;
onUnchecked(this: HTMLInputElement): void;
/**
* Callback before a checkbox is checked. Can cancel change by returning false
*/
beforeChecked(this: HTMLElement): boolean;
beforeChecked(this: HTMLInputElement): void | false;
/**
* Callback before a checkbox is set to undeterminate. Can cancel change by returning false
*/
beforeIndeterminate(this: HTMLElement): boolean;
beforeIndeterminate(this: HTMLInputElement): void | false;
/**
* Callback before a checkbox is set to determinate. Can cancel change by returning false
*/
beforeDeterminate(this: HTMLElement): boolean;
beforeDeterminate(this: HTMLInputElement): void | false;
/**
* Callback before a checkbox is unchecked. Can cancel change by returning false
*/
beforeUnchecked(this: HTMLElement): boolean;
beforeUnchecked(this: HTMLInputElement): void | false;
/**
* Callback after a checkbox is enabled.
*/
onEnable(this: HTMLElement): void;
onEnable(this: HTMLInputElement): void;
/**
* Callback after a checkbox is disabled.
*/
onDisable(this: HTMLElement): void;
onDisable(this: HTMLInputElement): void;
/**
* Callback after a checkbox is enabled.
*
* @deprecated
*/
onEnabled(this: HTMLElement): void;
onEnabled(this: HTMLInputElement): void;
/**
* Callback after a checkbox is disabled.
*
* @deprecated
*/
onDisabled(this: HTMLElement): void;
onDisabled(this: HTMLInputElement): void;
// endregion
@@ -248,10 +272,12 @@ declare namespace SemanticUI {
}
namespace Checkbox {
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'input'> |
Pick<_Impl, 'label'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -265,10 +291,14 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'checked'> |
Pick<_Impl, 'disabled'> |
Pick<_Impl, 'radio'> |
Pick<_Impl, 'readOnly'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -290,10 +320,11 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_checkbox_static() {
$.fn.checkbox.settings.error.method = 'method';
$.fn.checkbox.settings.error!.method = 'method';
$.fn.checkbox.settings.namespace = 'namespace';
$.fn.checkbox.settings.name = 'name';
$.fn.checkbox.settings.silent = false;
@@ -10,31 +10,32 @@ function test_checkbox_static() {
function test_checkbox() {
const selector = '.ui.checkbox';
$(selector).checkbox('toggle') === $();
$(selector).checkbox('check') === $();
$(selector).checkbox('uncheck') === $();
$(selector).checkbox('indeterminate') === $();
$(selector).checkbox('determinate') === $();
$(selector).checkbox('enable') === $();
$(selector).checkbox('set checked') === $();
$(selector).checkbox('set unchecked') === $();
$(selector).checkbox('set indeterminate') === $();
$(selector).checkbox('set determinate') === $();
$(selector).checkbox('set enabled') === $();
$(selector).checkbox('set disabled') === $();
$(selector).checkbox('attach events', $(), 'click') === $();
$(selector).checkbox('is radio') === true;
$(selector).checkbox('is checked') === true;
$(selector).checkbox('is unchecked') === true;
$(selector).checkbox('can change') === true;
$(selector).checkbox('should allow check') === true;
$(selector).checkbox('should allow uncheck') === true;
$(selector).checkbox('should allow determinate') === true;
$(selector).checkbox('should allow indeterminate') === true;
$(selector).checkbox('can uncheck') === true;
$(selector).checkbox('setting', 'debug', undefined) === false;
$(selector).checkbox('setting', 'debug') === false;
$(selector).checkbox('setting', 'debug', true) === $();
$(selector).checkbox('toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('check'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('uncheck'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('indeterminate'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('determinate'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('enable'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('set checked'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('set unchecked'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('set indeterminate'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('set determinate'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('set enabled'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('set disabled'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('attach events', $(), 'click'); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('is radio'); // $ExpectType boolean
$(selector).checkbox('is checked'); // $ExpectType boolean
$(selector).checkbox('is unchecked'); // $ExpectType boolean
$(selector).checkbox('can change'); // $ExpectType boolean
$(selector).checkbox('should allow check'); // $ExpectType boolean
$(selector).checkbox('should allow uncheck'); // $ExpectType boolean
$(selector).checkbox('should allow determinate'); // $ExpectType boolean
$(selector).checkbox('should allow indeterminate'); // $ExpectType boolean
$(selector).checkbox('can uncheck'); // $ExpectType boolean
$(selector).checkbox('setting', 'debug', undefined); // $ExpectType boolean
$(selector).checkbox('setting', 'debug'); // $ExpectType boolean
$(selector).checkbox('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).checkbox('setting', {
namespace: 'namespace',
name: 'name',
@@ -42,48 +43,57 @@ function test_checkbox() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).checkbox({
uncheckable: false,
fireOnInit: true,
onChange() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
onChecked() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
onIndeterminate() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
onDeterminate() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
onUnchecked() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
beforeChecked() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
return false;
},
beforeIndeterminate() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
return false;
},
beforeDeterminate() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
return false;
},
beforeUnchecked() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
return false;
},
onEnable() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
onDisable() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
onEnabled() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
onDisabled() {
this === new HTMLElement();
this; // $ExpectType HTMLInputElement
},
selector: {
input: 'input',
@@ -98,12 +108,16 @@ function test_checkbox() {
error: {
method: 'method'
}
}) === $();
$(selector).checkbox() === $();
});
$(selector).checkbox(); // $ExpectType JQuery<HTMLElement>
$(selector).checkbox('foo'); // $ExpectError
$(selector).checkbox({ foo: 'bar' }); // $ExpectError
}
import checkbox = require('semantic-ui-checkbox');
function test_module() {
checkbox; // $ExpectType Checkbox
$.fn.checkbox = checkbox;
}
+58 -10
View File
@@ -95,18 +95,41 @@ declare namespace SemanticUI {
*/
(behavior: 'set disabled'): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof DimmerSettings>(behavior: 'setting', name: K, value?: undefined): DimmerSettings[K];
<K extends keyof DimmerSettings>(behavior: 'setting', name: K, value: DimmerSettings[K]): JQuery;
(behavior: 'setting', value: DimmerSettings | object): JQuery;
(settings?: DimmerSettings | object): JQuery;
<K extends keyof DimmerSettings>(behavior: 'setting', name: K, value?: undefined): DimmerSettings._Impl[K];
<K extends keyof DimmerSettings>(behavior: 'setting', name: K, value: DimmerSettings._Impl[K]): JQuery;
(behavior: 'setting', value: DimmerSettings): JQuery;
(settings?: DimmerSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/dimmer.html#/settings}
*/
interface DimmerSettings extends Pick<DimmerSettings._Impl, keyof DimmerSettings._Impl> { }
type DimmerSettings = DimmerSettings.Param;
namespace DimmerSettings {
type Param = (Pick<_Impl, 'opacity'> |
Pick<_Impl, 'variation'> |
Pick<_Impl, 'dimmerName'> |
Pick<_Impl, 'closable'> |
Pick<_Impl, 'on'> |
Pick<_Impl, 'useCSS'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'onShow'> |
Pick<_Impl, 'onHide'> |
Pick<_Impl, 'onChange'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'template'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Behavior
@@ -244,9 +267,13 @@ declare namespace SemanticUI {
}
namespace Dimmer {
interface DurationSettings extends Pick<DurationSettings._Impl, keyof DurationSettings._Impl> { }
type DurationSettings = DurationSettings.Param;
namespace DurationSettings {
type Param = (Pick<_Impl, 'show'> |
Pick<_Impl, 'hide'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 500
@@ -259,9 +286,14 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = (Pick<_Impl, 'dimmable'> |
Pick<_Impl, 'dimmer'> |
Pick<_Impl, 'content'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default '.dimmable'
@@ -278,17 +310,30 @@ declare namespace SemanticUI {
}
}
interface TemplateSettings extends Pick<TemplateSettings._Impl, keyof TemplateSettings._Impl> { }
type TemplateSettings = TemplateSettings.Param;
namespace TemplateSettings {
type Param = (Pick<_Impl, 'dimmer'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
dimmer(): JQuery;
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'dimmable'> |
Pick<_Impl, 'dimmed'> |
Pick<_Impl, 'disabled'> |
Pick<_Impl, 'pageDimmer'> |
Pick<_Impl, 'hide'> |
Pick<_Impl, 'show'> |
Pick<_Impl, 'transition'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 'active'
@@ -325,9 +370,12 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = (Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 'The method you called is not defined.'
@@ -1,5 +1,5 @@
function test_dimmer_settings() {
$.fn.dimmer.settings.error.method = 'method';
$.fn.dimmer.settings.error!.method = 'method';
$.fn.dimmer.settings.namespace = 'namespace';
$.fn.dimmer.settings.name = 'name';
$.fn.dimmer.settings.silent = false;
@@ -10,32 +10,33 @@ function test_dimmer_settings() {
function test_dimmer() {
const selector = '.ui.dimmer';
$(selector).dimmer('add content', $()) === $();
$(selector).dimmer('show') === $();
$(selector).dimmer('hide') === $();
$(selector).dimmer('toggle') === $();
$(selector).dimmer('set opacity', 1) === $();
$(selector).dimmer('create') === $();
$(selector).dimmer('get duration') === 10;
$(selector).dimmer('get dimmer') === $();
$(selector).dimmer('has dimmer') === true;
$(selector).dimmer('is active') === true;
$(selector).dimmer('is animating') === true;
$(selector).dimmer('is dimmer') === true;
$(selector).dimmer('is dimmable') === true;
$(selector).dimmer('is disabled') === true;
$(selector).dimmer('is enabled') === true;
$(selector).dimmer('is page') === true;
$(selector).dimmer('is page dimmer') === true;
$(selector).dimmer('set active') === $();
$(selector).dimmer('set dimmable') === $();
$(selector).dimmer('set dimmed') === $();
$(selector).dimmer('set page dimmer') === $();
$(selector).dimmer('set disabled') === $();
$(selector).dimmer('destroy') === $();
$(selector).dimmer('setting', 'debug', undefined) === false;
$(selector).dimmer('setting', 'debug') === false;
$(selector).dimmer('setting', 'debug', true) === $();
$(selector).dimmer('add content', $()); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('show'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('set opacity', 1); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('create'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('get duration'); // $ExpectType number
$(selector).dimmer('get dimmer'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('has dimmer'); // $ExpectType boolean
$(selector).dimmer('is active'); // $ExpectType boolean
$(selector).dimmer('is animating'); // $ExpectType boolean
$(selector).dimmer('is dimmer'); // $ExpectType boolean
$(selector).dimmer('is dimmable'); // $ExpectType boolean
$(selector).dimmer('is disabled'); // $ExpectType boolean
$(selector).dimmer('is enabled'); // $ExpectType boolean
$(selector).dimmer('is page'); // $ExpectType boolean
$(selector).dimmer('is page dimmer'); // $ExpectType boolean
$(selector).dimmer('set active'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('set dimmable'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('set dimmed'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('set page dimmer'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('set disabled'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('setting', 'debug', undefined); // $ExpectType boolean
$(selector).dimmer('setting', 'debug'); // $ExpectType boolean
$(selector).dimmer('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).dimmer('setting', {
namespace: 'namespace',
name: 'name',
@@ -43,7 +44,8 @@ function test_dimmer() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).dimmer({
opacity: 1,
variation: 'variation',
@@ -57,13 +59,13 @@ function test_dimmer() {
},
transition: 'fade',
onShow() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onHide() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onChange() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
selector: {
dimmable: '.dimmable',
@@ -88,12 +90,16 @@ function test_dimmer() {
error: {
method: 'method'
}
}) === $();
$(selector).dimmer() === $();
});
$(selector).dimmer(); // $ExpectType JQuery<HTMLElement>
$(selector).dimmer('foo'); // $ExpectError
$(selector).dimmer({ foo: 'bar' }); // $ExpectError
}
import dimmer = require('semantic-ui-dimmer');
function test_module() {
dimmer; // $ExpectType Dimmer
$.fn.dimmer = dimmer;
}
+147 -26
View File
@@ -157,19 +157,71 @@ declare namespace SemanticUI {
*/
(behavior: 'get placeholder text'): string;
(behavior: 'destroy'): JQuery;
<K extends keyof DropdownSettings>(behavior: 'setting', name: K, value?: undefined): DropdownSettings[K];
<K extends keyof DropdownSettings>(behavior: 'setting', name: K, value: DropdownSettings[K]): JQuery;
(behavior: 'setting', value: DropdownSettings.Param): JQuery;
(settings?: DropdownSettings.Param): JQuery;
<K extends keyof DropdownSettings>(behavior: 'setting', name: K, value?: undefined): DropdownSettings._Impl[K];
<K extends keyof DropdownSettings>(behavior: 'setting', name: K, value: DropdownSettings._Impl[K]): JQuery;
(behavior: 'setting', value: DropdownSettings): JQuery;
(settings?: DropdownSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/dropdown.html#/settings}
*/
interface DropdownSettings extends Pick<DropdownSettings._Impl, keyof DropdownSettings._Impl> { }
type DropdownSettings = DropdownSettings.Param;
namespace DropdownSettings {
type Param = DropdownSettings | object;
type Param = (Pick<_Impl, 'on'> |
Pick<_Impl, 'allowReselection'> |
Pick<_Impl, 'allowAdditions'> |
Pick<_Impl, 'hideAdditions'> |
Pick<_Impl, 'action'> |
Pick<_Impl, 'minCharacters'> |
Pick<_Impl, 'match'> |
Pick<_Impl, 'selectOnKeydown'> |
Pick<_Impl, 'forceSelection'> |
Pick<_Impl, 'allowCategorySelection'> |
Pick<_Impl, 'placeholder'> |
Pick<_Impl, 'apiSettings'> |
Pick<_Impl, 'fields'> |
Pick<_Impl, 'saveRemoteData'> |
Pick<_Impl, 'filterRemoteData'> |
Pick<_Impl, 'useLabels'> |
Pick<_Impl, 'maxSelections'> |
Pick<_Impl, 'glyphWidth'> |
Pick<_Impl, 'label'> |
Pick<_Impl, 'direction'> |
Pick<_Impl, 'keepOnScreen'> |
Pick<_Impl, 'context'> |
Pick<_Impl, 'fullTextSearch'> |
Pick<_Impl, 'preserveHTML'> |
Pick<_Impl, 'sortSelect'> |
Pick<_Impl, 'showOnFocus'> |
Pick<_Impl, 'allowTab'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'keys'> |
Pick<_Impl, 'delay'> |
Pick<_Impl, 'onChange'> |
Pick<_Impl, 'onAdd'> |
Pick<_Impl, 'onRemove'> |
Pick<_Impl, 'onLabelCreate'> |
Pick<_Impl, 'onLabelRemove'> |
Pick<_Impl, 'onLabelSelect'> |
Pick<_Impl, 'onNoResults'> |
Pick<_Impl, 'onShow'> |
Pick<_Impl, 'onHide'> |
Pick<_Impl, 'message'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'regExp'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Frequently Used Settings
@@ -475,10 +527,14 @@ declare namespace SemanticUI {
}
namespace Dropdown {
interface FieldsSettings extends Pick<FieldsSettings._Impl, keyof FieldsSettings._Impl> { }
type FieldsSettings = FieldsSettings.Param;
namespace FieldsSettings {
type Param = FieldsSettings | object;
type Param = (Pick<_Impl, 'remoteValues'> |
Pick<_Impl, 'values'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'value'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -508,10 +564,13 @@ declare namespace SemanticUI {
}
}
interface LabelSettings extends Pick<LabelSettings._Impl, keyof LabelSettings._Impl> { }
type LabelSettings = LabelSettings.Param;
namespace LabelSettings {
type Param = LabelSettings | object;
type Param = (Pick<_Impl, 'transition'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'variation'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -529,10 +588,21 @@ declare namespace SemanticUI {
}
}
interface KeySettings extends Pick<KeySettings._Impl, keyof KeySettings._Impl> { }
type KeySettings = KeySettings.Param;
namespace KeySettings {
type Param = KeySettings | object;
type Param = (Pick<_Impl, 'backspace'> |
Pick<_Impl, 'delimiter'> |
Pick<_Impl, 'deleteKey'> |
Pick<_Impl, 'enter'> |
Pick<_Impl, 'escape'> |
Pick<_Impl, 'pageUp'> |
Pick<_Impl, 'pageDown'> |
Pick<_Impl, 'leftArrow'> |
Pick<_Impl, 'upArrow'> |
Pick<_Impl, 'rightArrow'> |
Pick<_Impl, 'downArrow'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -582,10 +652,14 @@ declare namespace SemanticUI {
}
}
interface DelaySettings extends Pick<DelaySettings._Impl, keyof DelaySettings._Impl> { }
type DelaySettings = DelaySettings.Param;
namespace DelaySettings {
type Param = DelaySettings | object;
type Param = (Pick<_Impl, 'hide'> |
Pick<_Impl, 'show'> |
Pick<_Impl, 'search'> |
Pick<_Impl, 'touch'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -607,10 +681,14 @@ declare namespace SemanticUI {
}
}
interface MessageSettings extends Pick<MessageSettings._Impl, keyof MessageSettings._Impl> { }
type MessageSettings = MessageSettings.Param;
namespace MessageSettings {
type Param = MessageSettings | object;
type Param = (Pick<_Impl, 'addResult'> |
Pick<_Impl, 'count'> |
Pick<_Impl, 'maxSelections'> |
Pick<_Impl, 'noResults'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -632,10 +710,23 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'addition'> |
Pick<_Impl, 'dropdown'> |
Pick<_Impl, 'icon'> |
Pick<_Impl, 'input'> |
Pick<_Impl, 'item'> |
Pick<_Impl, 'label'> |
Pick<_Impl, 'remove'> |
Pick<_Impl, 'siblingLabel'> |
Pick<_Impl, 'menu'> |
Pick<_Impl, 'message'> |
Pick<_Impl, 'menuIcon'> |
Pick<_Impl, 'search'> |
Pick<_Impl, 'text'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -693,10 +784,11 @@ declare namespace SemanticUI {
}
}
interface RegExpSettings extends Pick<RegExpSettings._Impl, keyof RegExpSettings._Impl> { }
type RegExpSettings = RegExpSettings.Param;
namespace RegExpSettings {
type Param = RegExpSettings | object;
type Param = (Pick<_Impl, 'escape'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -706,10 +798,15 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = MetadataSettings | object;
type Param = (Pick<_Impl, 'defaultText'> |
Pick<_Impl, 'defaultValue'> |
Pick<_Impl, 'placeholderText'> |
Pick<_Impl, 'text'> |
Pick<_Impl, 'value'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -735,10 +832,29 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'addition'> |
Pick<_Impl, 'animating'> |
Pick<_Impl, 'disabled'> |
Pick<_Impl, 'dropdown'> |
Pick<_Impl, 'filtered'> |
Pick<_Impl, 'hidden'> |
Pick<_Impl, 'item'> |
Pick<_Impl, 'label'> |
Pick<_Impl, 'loading'> |
Pick<_Impl, 'menu'> |
Pick<_Impl, 'message'> |
Pick<_Impl, 'multiple'> |
Pick<_Impl, 'placeholder'> |
Pick<_Impl, 'search'> |
Pick<_Impl, 'selected'> |
Pick<_Impl, 'selection'> |
Pick<_Impl, 'upward'> |
Pick<_Impl, 'visible'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -820,10 +936,15 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'action'> |
Pick<_Impl, 'alreadySetup'> |
Pick<_Impl, 'labels'> |
Pick<_Impl, 'method'> |
Pick<_Impl, 'noTransition'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_dropdown_static() {
$.fn.dropdown.settings.error.method = 'method';
$.fn.dropdown.settings.error!.method = 'method';
$.fn.dropdown.settings.namespace = 'namespace';
$.fn.dropdown.settings.name = 'name';
$.fn.dropdown.settings.silent = false;
@@ -10,47 +10,48 @@ function test_dropdown_static() {
function test_dropdown() {
const selector = '.ui.dropdown';
$(selector).dropdown('setup menu') === $();
$(selector).dropdown('refresh') === $();
$(selector).dropdown('toggle') === $();
$(selector).dropdown('show') === $();
$(selector).dropdown('hide') === $();
$(selector).dropdown('clear') === $();
$(selector).dropdown('hide others') === $();
$(selector).dropdown('restore defaults') === $();
$(selector).dropdown('restore default text') === $();
$(selector).dropdown('restore placeholder text') === $();
$(selector).dropdown('restore default value') === $();
$(selector).dropdown('save defaults') === $();
$(selector).dropdown('set selected', 123) === $();
$(selector).dropdown('remove selected', false) === $();
$(selector).dropdown('set selected', ['456']) === $();
$(selector).dropdown('set exactly', []) === $();
$(selector).dropdown('set text', 'hello') === $();
$(selector).dropdown('set value', 24) === $();
$(selector).dropdown('get text') === 'text';
$(selector).dropdown('get value') === {};
$(selector).dropdown('get item', 'Pennsylvania') === $();
$(selector).dropdown('bind touch events') === $();
$(selector).dropdown('bind mouse events') === $();
$(selector).dropdown('bind intent') === $();
$(selector).dropdown('unbind intent') === $();
$(selector).dropdown('determine intent') === true;
$(selector).dropdown('determine select action', 'text', 90) === $();
$(selector).dropdown('set active') === $();
$(selector).dropdown('set visible') === $();
$(selector).dropdown('remove active') === $();
$(selector).dropdown('remove visible') === $();
$(selector).dropdown('is selection') === false;
$(selector).dropdown('is animated') === false;
$(selector).dropdown('is visible') === false;
$(selector).dropdown('is hidden') === false;
$(selector).dropdown('setup menu'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('refresh'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('show'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('clear'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('hide others'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('restore defaults'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('restore default text'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('restore placeholder text'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('restore default value'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('save defaults'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('set selected', 123); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('remove selected', false); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('set selected', ['456']); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('set exactly', []); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('set text', 'hello'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('set value', 24); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('get text'); // $ExpectType string
$(selector).dropdown('get value'); // $ExpectType any
$(selector).dropdown('get item', 'Pennsylvania'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('bind touch events'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('bind mouse events'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('bind intent'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('unbind intent'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('determine intent'); // $ExpectType boolean
$(selector).dropdown('determine select action', 'text', 90); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('set active'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('set visible'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('remove active'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('remove visible'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('is selection'); // $ExpectType boolean
$(selector).dropdown('is animated'); // $ExpectType boolean
$(selector).dropdown('is visible'); // $ExpectType boolean
$(selector).dropdown('is hidden'); // $ExpectType boolean
$(selector).dropdown('get default text') === 'default text';
$(selector).dropdown('get placeholder text') === 'placeholder text';
$(selector).dropdown('destroy') === $();
$(selector).dropdown('setting', 'debug', undefined) === false;
$(selector).dropdown('setting', 'debug') === false;
$(selector).dropdown('setting', 'debug', true) === $();
$(selector).dropdown('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('setting', 'debug', undefined); // $ExpectType boolean
$(selector).dropdown('setting', 'debug'); // $ExpectType boolean
$(selector).dropdown('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).dropdown('setting', {
namespace: 'namespace',
name: 'name',
@@ -58,19 +59,18 @@ function test_dropdown() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).dropdown({
on: 'hover',
allowReselection: true,
allowAdditions: false,
hideAdditions: true,
action(text, value, element) {
this === $();
text === 'text';
if (typeof value !== 'string') {
value === false;
}
element === $();
this; // $ExpectType JQuery<HTMLElement>
text; // $ExpectType string
value; // $ExpectType string | false
element; // $ExpectType JQuery<HTMLElement>
},
minCharacters: 2,
match: 'text',
@@ -79,9 +79,107 @@ function test_dropdown() {
allowCategorySelection: false,
placeholder: 'value',
apiSettings: {
cache: 'local',
on: 'on',
cache: true,
stateContext: $(),
encodeParameters: false,
defaultData: true,
serializeForm: false,
throttle: 10,
throttleFirstRequest: true,
loadingDuration: 20
interruptRequests: false,
loadingDuration: 3,
hideError: true,
errorDuration: 10,
action: 'action',
url: 'url',
urlData: false,
response: false,
responseAsync(settings, callback) {
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
mockResponse: false,
mockResponseAsync(settings, callback) {
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
method: 'post',
dataType: 'xml',
data: {},
beforeSend(settings) {
settings; // $ExpectType Param
},
beforeXHR(xhrObject) {
xhrObject; // $ExpectType jqXHR<any>
},
onRequest(promise, xhr) {
promise; // $ExpectType Deferred<any, any, any>
xhr; // $ExpectType jqXHR<any>
},
onResponse(response) {
response; // $ExpectType any
},
successTest(response) {
response; // $ExpectType any
return false;
},
onSuccess(response, element, xhr) {
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onComplete(response, element, xhr) {
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onFailure(response, element) {
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
},
onError(errorMessage, element, xhr) {
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onAbort(errorMessage, element, xhr) {
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
regExp: {
required: /{\$*[A-z0-9]+}/g,
optional: /{\/\$*[A-z0-9]+}/g
},
selector: {
disabled: '.disabled',
form: 'form'
},
className: {
loading: 'loading',
error: 'error'
},
metadata: {
action: 'action',
url: 'url'
},
error: {
beforeSend: 'beforeSend',
error: 'error',
exitConditions: 'exitConditions',
JSONParse: 'JSONParse',
legacyParameters: 'legacyParameters',
missingAction: 'missingAction',
missingSerialize: 'missingSerialize',
missingURL: 'missingURL',
noReturnedValue: 'noReturnedValue',
parseError: 'parseError',
requiredParameter: 'requiredParameter',
statusMessage: 'statusMessage',
timeout: 'timeout'
}
},
fields: {
remoteValues: 'remoteValues',
@@ -129,14 +227,14 @@ function test_dropdown() {
touch: 50
},
onChange(value, text, $choice) {
value === {};
text === 'text';
$choice === $();
value; // $ExpectType any
text; // $ExpectType string
$choice; // $ExpectType JQuery<HTMLElement>
},
onAdd(addedValue, addedText, $addedChoice) {
addedValue === {};
addedText === 'addedText';
$addedChoice === $();
addedValue; // $ExpectType any
addedText; // $ExpectType string
$addedChoice; // $ExpectType JQuery<HTMLElement>
},
message: {
addResult: 'addResult',
@@ -197,12 +295,16 @@ function test_dropdown() {
method: 'method',
noTransition: 'noTransition'
}
}) === $();
$(selector).dropdown() === $();
});
$(selector).dropdown(); // $ExpectType JQuery<HTMLElement>
$(selector).dropdown('foo'); // $ExpectError
$(selector).dropdown({ foo: 'bar' }); // $ExpectError
}
import dropdown = require('semantic-ui-dropdown');
function test_module() {
dropdown; // $ExpectType Dropdown
$.fn.dropdown = dropdown;
}
+56 -18
View File
@@ -50,19 +50,43 @@ declare namespace SemanticUI {
* Destroys instance and removes all events
*/
(behavior: 'destroy'): JQuery;
<K extends keyof EmbedSettings>(behavior: 'setting', name: K, value?: undefined): EmbedSettings[K];
<K extends keyof EmbedSettings>(behavior: 'setting', name: K, value: EmbedSettings[K]): JQuery;
(behavior: 'setting', value: EmbedSettings.Param): JQuery;
(settings?: EmbedSettings.Param): JQuery;
<K extends keyof EmbedSettings>(behavior: 'setting', name: K, value?: undefined): EmbedSettings._Impl[K];
<K extends keyof EmbedSettings>(behavior: 'setting', name: K, value: EmbedSettings._Impl[K]): JQuery;
(behavior: 'setting', value: EmbedSettings): JQuery;
(settings?: EmbedSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/embed.html#/settings}
*/
interface EmbedSettings extends Pick<EmbedSettings._Impl, keyof EmbedSettings._Impl> { }
type EmbedSettings = EmbedSettings.Param;
namespace EmbedSettings {
type Param = EmbedSettings | object;
type Param = (Pick<_Impl, 'url'> |
Pick<_Impl, 'icon'> |
Pick<_Impl, 'source'> |
Pick<_Impl, 'id'> |
Pick<_Impl, 'parameters'> |
Pick<_Impl, 'autoplay'> |
Pick<_Impl, 'color'> |
Pick<_Impl, 'hd'> |
Pick<_Impl, 'brandedUI'> |
Pick<_Impl, 'onCreate'> |
Pick<_Impl, 'onDisplay'> |
Pick<_Impl, 'onPlaceholderDisplay'> |
Pick<_Impl, 'onEmbed'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'templates'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -216,20 +240,23 @@ declare namespace SemanticUI {
}
namespace Embed {
interface ParametersSettings extends Pick<ParametersSettings._Impl, keyof ParametersSettings._Impl> { }
type ParametersSettings = ParametersSettings._Impl;
namespace ParametersSettings {
type Param = ParametersSettings | object;
type Param = _Impl;
interface _Impl {
[key: string]: any;
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'embed'> |
Pick<_Impl, 'placeholder'> |
Pick<_Impl, 'play'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -247,10 +274,15 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = MetadataSettings | object;
type Param = (Pick<_Impl, 'id'> |
Pick<_Impl, 'icon'> |
Pick<_Impl, 'placeholder'> |
Pick<_Impl, 'source'> |
Pick<_Impl, 'url'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -276,10 +308,12 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'embed'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -293,10 +327,12 @@ declare namespace SemanticUI {
}
}
interface TemplatesSettings extends Pick<TemplatesSettings._Impl, keyof TemplatesSettings._Impl> { }
type TemplatesSettings = TemplatesSettings.Param;
namespace TemplatesSettings {
type Param = TemplatesSettings | object;
type Param = (Pick<_Impl, 'iframe'> |
Pick<_Impl, 'placeholder'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -310,10 +346,12 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'noURL'> |
Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_embed_static() {
$.fn.embed.settings.error.method = 'method';
$.fn.embed.settings.error!.method = 'method';
$.fn.embed.settings.namespace = 'namespace';
$.fn.embed.settings.name = 'name';
$.fn.embed.settings.silent = false;
@@ -10,20 +10,21 @@ function test_embed_static() {
function test_embed() {
const selector = '.ui.embed';
$(selector).embed('change', 'source', 'id', 'url') === $();
$(selector).embed('reset') === $();
$(selector).embed('show') === $();
$(selector).embed('hide') === $();
$(selector).embed('get id') === 'get';
$(selector).embed('get placeholder') === 'get';
$(selector).embed('get sources') === 'get';
$(selector).embed('get type') === 'get';
$(selector).embed('get url') === 'get';
$(selector).embed('change', 'source', 'id', 'url'); // $ExpectType JQuery<HTMLElement>
$(selector).embed('reset'); // $ExpectType JQuery<HTMLElement>
$(selector).embed('show'); // $ExpectType JQuery<HTMLElement>
$(selector).embed('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).embed('get id'); // $ExpectType string
$(selector).embed('get placeholder'); // $ExpectType string
$(selector).embed('get sources'); // $ExpectType string
$(selector).embed('get type'); // $ExpectType string
$(selector).embed('get url'); // $ExpectType string
$(selector).embed('has placeholder') === true;
$(selector).embed('destroy') === $();
$(selector).embed('setting', 'debug', undefined) === false;
$(selector).embed('setting', 'debug') === false;
$(selector).embed('setting', 'debug', true) === $();
$(selector).embed('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).embed('setting', 'debug', undefined); // $ExpectType boolean
$(selector).embed('setting', 'debug'); // $ExpectType boolean
$(selector).embed('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).embed('setting', {
namespace: 'namespace',
name: 'name',
@@ -31,7 +32,8 @@ function test_embed() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).embed({
url: 'url',
icon: 'icon',
@@ -45,18 +47,19 @@ function test_embed() {
hd: false,
brandedUI: true,
onCreate(url) {
this === $();
url === 'url';
this; // $ExpectType JQuery<HTMLElement>
url; // $ExpectType string
},
onDisplay() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onPlaceholderDisplay() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onEmbed(parameters) {
this === $();
parameters.key = 'value';
this; // $ExpectType JQuery<HTMLElement>
parameters; // $ExpectType _Impl
return parameters;
},
selector: {
@@ -77,26 +80,32 @@ function test_embed() {
},
templates: {
iframe(url, parameters) {
url === 'url';
parameters === 'parameters';
return url + parameters;
url; // $ExpectType string
parameters; // $ExpectType string
return '<div></div>';
},
placeholder(image, icon) {
image === 'image';
icon === 'icon';
return image + icon;
image; // $ExpectType string
icon; // $ExpectType string
return '<div></div>';
}
},
error: {
noURL: 'noURL',
method: 'method'
}
}) === $();
$(selector).embed() === $();
});
$(selector).embed(); // $ExpectType JQuery<HTMLElement>
$(selector).embed('foo'); // $ExpectError
$(selector).embed({ foo: 'bar' }); // $ExpectError
}
import embed = require('semantic-ui-embed');
function test_module() {
embed; // $ExpectType Embed
$.fn.embed = embed;
}
+89 -21
View File
@@ -55,19 +55,45 @@ declare namespace SemanticUI {
*/
(behavior: 'add errors', errors: string[]): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof FormSettings>(behavior: 'setting', name: K, value?: undefined): FormSettings[K];
<K extends keyof FormSettings>(behavior: 'setting', name: K, value: FormSettings[K]): JQuery;
(behavior: 'setting', value: FormSettings.Param): JQuery;
(settings?: FormSettings.Param): JQuery;
<K extends keyof FormSettings>(behavior: 'setting', name: K, value?: undefined): FormSettings._Impl[K];
<K extends keyof FormSettings>(behavior: 'setting', name: K, value: FormSettings._Impl[K]): JQuery;
(behavior: 'setting', value: FormSettings): JQuery;
(settings?: FormSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/behaviors/form.html#/settings}
*/
interface FormSettings extends Pick<FormSettings._Impl, keyof FormSettings._Impl> { }
type FormSettings = FormSettings.Param;
namespace FormSettings {
type Param = FormSettings | object;
type Param = (Pick<_Impl, 'keyboardShortcuts'> |
Pick<_Impl, 'on'> |
Pick<_Impl, 'revalidate'> |
Pick<_Impl, 'delay'> |
Pick<_Impl, 'inline'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'fields'> |
Pick<_Impl, 'text'> |
Pick<_Impl, 'prompt'> |
Pick<_Impl, 'onValid'> |
Pick<_Impl, 'onInvalid'> |
Pick<_Impl, 'onSuccess'> |
Pick<_Impl, 'onFailure'> |
Pick<_Impl, 'templates'> |
Pick<_Impl, 'rules'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Form Settings
@@ -141,7 +167,7 @@ declare namespace SemanticUI {
/**
* Callback if a form is all valid
*/
onSuccess(this: JQuery, event: JQueryEventObject, fields: any): void;
onSuccess(this: JQuery, event: JQuery.Event<HTMLElement>, fields: any): void;
/**
* Callback if any form field is invalid
*/
@@ -237,10 +263,12 @@ declare namespace SemanticUI {
prompt: string;
}
interface TextSettings extends Pick<TextSettings._Impl, keyof TextSettings._Impl> { }
type TextSettings = TextSettings.Param;
namespace TextSettings {
type Param = TextSettings | object;
type Param = (Pick<_Impl, 'unspecifiedRule'> |
Pick<_Impl, 'unspecifiedField'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -254,10 +282,36 @@ declare namespace SemanticUI {
}
}
interface PromptSettings extends Pick<PromptSettings._Impl, keyof PromptSettings._Impl> { }
type PromptSettings = PromptSettings.Param;
namespace PromptSettings {
type Param = PromptSettings | object;
type Param = (Pick<_Impl, 'empty'> |
Pick<_Impl, 'checked'> |
Pick<_Impl, 'email'> |
Pick<_Impl, 'url'> |
Pick<_Impl, 'regExp'> |
Pick<_Impl, 'integer'> |
Pick<_Impl, 'decimal'> |
Pick<_Impl, 'number'> |
Pick<_Impl, 'is'> |
Pick<_Impl, 'isExactly'> |
Pick<_Impl, 'not'> |
Pick<_Impl, 'notExactly'> |
Pick<_Impl, 'contain'> |
Pick<_Impl, 'containExactly'> |
Pick<_Impl, 'doesntContain'> |
Pick<_Impl, 'doesntContainExactly'> |
Pick<_Impl, 'minLength'> |
Pick<_Impl, 'length'> |
Pick<_Impl, 'exactLength'> |
Pick<_Impl, 'maxLength'> |
Pick<_Impl, 'match'> |
Pick<_Impl, 'different'> |
Pick<_Impl, 'creditCard'> |
Pick<_Impl, 'minCount'> |
Pick<_Impl, 'exactCount'> |
Pick<_Impl, 'maxCount'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -367,10 +421,12 @@ declare namespace SemanticUI {
}
}
interface TemplatesSettings extends Pick<TemplatesSettings._Impl, keyof TemplatesSettings._Impl> { }
type TemplatesSettings = TemplatesSettings.Param;
namespace TemplatesSettings {
type Param = TemplatesSettings | object;
type Param = (Pick<_Impl, 'error'> |
Pick<_Impl, 'prompt'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
error(errors: string[]): JQuery;
@@ -378,10 +434,16 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'message'> |
Pick<_Impl, 'field'> |
Pick<_Impl, 'group'> |
Pick<_Impl, 'input'> |
Pick<_Impl, 'prompt'> |
Pick<_Impl, 'submit'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -411,10 +473,11 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = MetadataSettings | object;
type Param = (Pick<_Impl, 'validate'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -424,10 +487,14 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'placeholder'> |
Pick<_Impl, 'disabled'> |
Pick<_Impl, 'visible'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -449,10 +516,11 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_form_static() {
$.fn.form.settings.error.method = 'method';
$.fn.form.settings.error!.method = 'method';
$.fn.form.settings.namespace = 'namespace';
$.fn.form.settings.name = 'name';
$.fn.form.settings.silent = false;
@@ -10,22 +10,23 @@ function test_form_static() {
function test_form() {
const selector = '.ui.form';
$(selector).form('submit') === $();
$(selector).form('is valid') === false;
$(selector).form('validate form') === $();
$(selector).form('submit'); // $ExpectType JQuery<HTMLElement>
$(selector).form('is valid'); // $ExpectType boolean
$(selector).form('validate form'); // $ExpectType JQuery<HTMLElement>
$(selector).form('get change event') === 'change event';
$(selector).form('get field', 'id') === $();
$(selector).form('get value', 'id') === {};
$(selector).form('get values', ['id1', 'id2']) === {};
$(selector).form('set value', 'id') === $();
$(selector).form('set values', ['id1', 'id2']) === $();
$(selector).form('get validation', $()) === {};
$(selector).form('has field', 'identifier') === true;
$(selector).form('add errors', ['error1', 'error2']) === $();
$(selector).form('destroy') === $();
$(selector).form('setting', 'debug', undefined) === false;
$(selector).form('setting', 'debug') === false;
$(selector).form('setting', 'debug', true) === $();
$(selector).form('get field', 'id'); // $ExpectType JQuery<HTMLElement>
$(selector).form('get value', 'id'); // $ExpectType any
$(selector).form('get values', ['id1', 'id2']); // $ExpectType any
$(selector).form('set value', 'id'); // $ExpectType JQuery<HTMLElement>
$(selector).form('set values', ['id1', 'id2']); // $ExpectType JQuery<HTMLElement>
$(selector).form('get validation', $()); // $ExpectType any
$(selector).form('has field', 'identifier'); // $ExpectType boolean
$(selector).form('add errors', ['error1', 'error2']); // $ExpectType JQuery<HTMLElement>
$(selector).form('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).form('setting', 'debug', undefined); // $ExpectType boolean
$(selector).form('setting', 'debug'); // $ExpectType boolean
$(selector).form('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).form('setting', {
namespace: 'namespace',
name: 'name',
@@ -33,12 +34,13 @@ function test_form() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).form({
keyboardShortcuts: false,
on: 'submit',
revalidate: true,
delay: 20,
delay: false,
inline: false,
transition: 'fade',
duration: 22,
@@ -92,36 +94,43 @@ function test_form() {
maxCount: 'maxCount'
},
onValid() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onInvalid() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onSuccess(event, fields) {
this === $();
event.stopPropagation();
fields === {};
this; // $ExpectType JQuery<HTMLElement>
event; // $ExpectType Event<HTMLElement, null>
fields; // $ExpectType any
},
onFailure(formErrors, fields) {
this === $();
formErrors === [];
fields === {};
this; // $ExpectType JQuery<HTMLElement>
formErrors; // $ExpectType string[]
fields; // $ExpectType any
},
templates: {
error(errors) {
errors === [];
errors; // $ExpectType string[]
return $();
},
prompt(errors) {
errors === [];
errors; // $ExpectType string[]
return $();
}
},
rules: {
empty(value) {
this; // $ExpectType HTMLElement
value; // $ExpectType any
return !(value === undefined || '' === value || $.isArray(value) && value.length === 0);
},
checked() {
this; // $ExpectType HTMLElement
return ($(this).filter(':checked').length > 0);
}
},
@@ -145,12 +154,16 @@ function test_form() {
error: {
method: 'method'
}
}) === $();
$(selector).form() === $();
});
$(selector).form(); // $ExpectType JQuery<HTMLElement>
$(selector).form('foo'); // $ExpectError
$(selector).form({ foo: 'bar' }); // $ExpectError
}
import form = require('semantic-ui-form');
function test_module() {
form; // $ExpectType Form
$.fn.form = form;
}
+45 -12
View File
@@ -56,19 +56,46 @@ declare namespace SemanticUI {
(behavior: 'set active'): JQuery;
(behavior: 'attach events', selector: string | JQuery, event?: string): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof ModalSettings>(behavior: 'setting', name: K, value?: undefined): ModalSettings[K];
<K extends keyof ModalSettings>(behavior: 'setting', name: K, value: ModalSettings[K]): JQuery;
(behavior: 'setting', value: ModalSettings.Param): JQuery;
(settings?: ModalSettings.Param): JQuery;
<K extends keyof ModalSettings>(behavior: 'setting', name: K, value?: undefined): ModalSettings._Impl[K];
<K extends keyof ModalSettings>(behavior: 'setting', name: K, value: ModalSettings._Impl[K]): JQuery;
(behavior: 'setting', value: ModalSettings): JQuery;
(settings?: ModalSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/modal.html#/settings}
*/
interface ModalSettings extends Pick<ModalSettings._Impl, keyof ModalSettings._Impl> { }
type ModalSettings = ModalSettings.Param;
namespace ModalSettings {
type Param = ModalSettings | object;
type Param = (Pick<_Impl, 'detachable'> |
Pick<_Impl, 'autofocus'> |
Pick<_Impl, 'observeChanges'> |
Pick<_Impl, 'allowMultiple'> |
Pick<_Impl, 'keyboardShortcuts'> |
Pick<_Impl, 'offset'> |
Pick<_Impl, 'context'> |
Pick<_Impl, 'closable'> |
Pick<_Impl, 'dimmerSettings'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'queue'> |
Pick<_Impl, 'onShow'> |
Pick<_Impl, 'onVisible'> |
Pick<_Impl, 'onHide'> |
Pick<_Impl, 'onHidden'> |
Pick<_Impl, 'onApprove'> |
Pick<_Impl, 'onDeny'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Modal Settings
@@ -232,10 +259,13 @@ declare namespace SemanticUI {
}
namespace Modal {
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'close'> |
Pick<_Impl, 'approve'> |
Pick<_Impl, 'deny'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -253,10 +283,12 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'scrolling'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -270,10 +302,11 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_modal_static() {
$.fn.modal.settings.error.method = 'method';
$.fn.modal.settings.error!.method = 'method';
$.fn.modal.settings.namespace = 'namespace';
$.fn.modal.settings.name = 'name';
$.fn.modal.settings.silent = false;
@@ -10,23 +10,24 @@ function test_modal_static() {
function test_modal() {
const selector = '.ui.modal';
$(selector).modal('show') === $();
$(selector).modal('hide') === $();
$(selector).modal('toggle') === $();
$(selector).modal('refresh') === $();
$(selector).modal('show dimmer') === $();
$(selector).modal('hide dimmer') === $();
$(selector).modal('hide others') === $();
$(selector).modal('hide all') === $();
$(selector).modal('cache sizes') === $();
$(selector).modal('can fit') === true;
$(selector).modal('is active') === true;
$(selector).modal('set active') === $();
$(selector).modal('attach events', 'selector', 'blur') === $();
$(selector).modal('destroy') === $();
$(selector).modal('setting', 'debug', undefined) === false;
$(selector).modal('setting', 'debug') === false;
$(selector).modal('setting', 'debug', true) === $();
$(selector).modal('show'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('refresh'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('show dimmer'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('hide dimmer'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('hide others'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('hide all'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('cache sizes'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('can fit'); // $ExpectType boolean
$(selector).modal('is active'); // $ExpectType boolean
$(selector).modal('set active'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('attach events', 'selector', 'blur'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).modal('setting', 'debug', undefined); // $ExpectType boolean
$(selector).modal('setting', 'debug'); // $ExpectType boolean
$(selector).modal('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).modal('setting', {
namespace: 'namespace',
name: 'name',
@@ -34,7 +35,8 @@ function test_modal() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).modal({
detachable: true,
autofocus: false,
@@ -57,13 +59,13 @@ function test_modal() {
},
transition: 'fade',
onShow() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onHide() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onChange() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
selector: {
dimmable: '.dimmable',
@@ -93,27 +95,30 @@ function test_modal() {
duration: 400,
queue: true,
onShow() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onVisible() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onHide($element) {
this === $();
$element === $();
this; // $ExpectType JQuery<HTMLElement>
$element; // $ExpectType JQuery<HTMLElement>
return false;
},
onHidden() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onApprove($element) {
this === $();
$element === $();
this; // $ExpectType JQuery<HTMLElement>
$element; // $ExpectType JQuery<HTMLElement>
return false;
},
onDeny($element) {
this === $();
$element === $();
this; // $ExpectType JQuery<HTMLElement>
$element; // $ExpectType JQuery<HTMLElement>
return false;
},
selector: {
@@ -128,12 +133,16 @@ function test_modal() {
error: {
method: 'method'
}
}) === $();
$(selector).modal() === $();
});
$(selector).modal(); // $ExpectType JQuery<HTMLElement>
$(selector).modal('foo'); // $ExpectError
$(selector).modal({ foo: 'bar' }); // $ExpectError
}
import modal = require('semantic-ui-modal');
function test_module() {
modal; // $ExpectType Modal
$.fn.modal = modal;
}
+45 -14
View File
@@ -13,19 +13,42 @@ declare namespace SemanticUI {
*/
(behavior: 'clear'): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof NagSettings>(behavior: 'setting', name: K, value?: undefined): NagSettings[K];
<K extends keyof NagSettings>(behavior: 'setting', name: K, value: NagSettings[K]): JQuery;
(behavior: 'setting', value: NagSettings.Param): JQuery;
(settings?: NagSettings.Param): JQuery;
<K extends keyof NagSettings>(behavior: 'setting', name: K, value?: undefined): NagSettings._Impl[K];
<K extends keyof NagSettings>(behavior: 'setting', name: K, value: NagSettings._Impl[K]): JQuery;
(behavior: 'setting', value: NagSettings): JQuery;
(settings?: NagSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/nag.html}
*/
interface NagSettings extends Pick<NagSettings._Impl, keyof NagSettings._Impl> { }
type NagSettings = NagSettings.Param;
namespace NagSettings {
type Param = NagSettings | object;
type Param = (Pick<_Impl, 'persist'> |
Pick<_Impl, 'displayTime'> |
Pick<_Impl, 'animation'> |
Pick<_Impl, 'context'> |
Pick<_Impl, 'detachable'> |
Pick<_Impl, 'expires'> |
Pick<_Impl, 'domain'> |
Pick<_Impl, 'path'> |
Pick<_Impl, 'storageMethod'> |
Pick<_Impl, 'key'> |
Pick<_Impl, 'value'> |
Pick<_Impl, 'speed'> |
Pick<_Impl, 'easing'> |
Pick<_Impl, 'onHide'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Behavior
@@ -152,10 +175,12 @@ declare namespace SemanticUI {
}
namespace Nag {
interface AnimationSettings extends Pick<AnimationSettings._Impl, keyof AnimationSettings._Impl> { }
type AnimationSettings = AnimationSettings.Param;
namespace AnimationSettings {
type Param = AnimationSettings | object;
type Param = (Pick<_Impl, 'show'> |
Pick<_Impl, 'hide'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -169,10 +194,12 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'bottom'> |
Pick<_Impl, 'fixed'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -186,10 +213,11 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'close'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -199,10 +227,13 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'noCookieStorage'> |
Pick<_Impl, 'noStorage'> |
Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
+18 -12
View File
@@ -1,5 +1,5 @@
function test_nag_static() {
$.fn.nag.settings.error.method = 'method';
$.fn.nag.settings.error!.method = 'method';
$.fn.nag.settings.namespace = 'namespace';
$.fn.nag.settings.name = 'name';
$.fn.nag.settings.silent = false;
@@ -10,13 +10,14 @@ function test_nag_static() {
function test_nag() {
const selector = '.ui.nag';
$(selector).nag('show') === $();
$(selector).nag('hide') === $();
$(selector).nag('clear') === $();
$(selector).nag('destroy') === $();
$(selector).nag('setting', 'debug', undefined) === false;
$(selector).nag('setting', 'debug') === false;
$(selector).nag('setting', 'debug', true) === $();
$(selector).nag('show'); // $ExpectType JQuery<HTMLElement>
$(selector).nag('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).nag('clear'); // $ExpectType JQuery<HTMLElement>
$(selector).nag('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).nag('setting', 'debug', undefined); // $ExpectType boolean
$(selector).nag('setting', 'debug'); // $ExpectType boolean
$(selector).nag('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).nag('setting', {
namespace: 'namespace',
name: 'name',
@@ -24,7 +25,8 @@ function test_nag() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).nag({
persist: true,
displayTime: 0,
@@ -43,7 +45,7 @@ function test_nag() {
speed: 500,
easing: 'easeOutQuad',
onHide() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
className: {
bottom: 'bottom',
@@ -57,12 +59,16 @@ function test_nag() {
noStorage: 'noStorage',
method: 'method'
}
}) === $();
$(selector).nag() === $();
});
$(selector).nag(); // $ExpectType JQuery<HTMLElement>
$(selector).nag('foo'); // $ExpectError
$(selector).nag({ foo: 'bar' }); // $ExpectError
}
import nag = require('semantic-ui-nag');
function test_module() {
nag; // $ExpectType Nag
$.fn.nag = nag;
}
+81 -16
View File
@@ -58,19 +58,66 @@ declare namespace SemanticUI {
* Removes popup from the page
*/
(behavior: 'remove popup'): JQuery;
<K extends keyof PopupSettings>(behavior: 'setting', name: K, value?: undefined): PopupSettings[K];
<K extends keyof PopupSettings>(behavior: 'setting', name: K, value: PopupSettings[K]): JQuery;
(behavior: 'setting', value: PopupSettings.Param): JQuery;
(settings?: PopupSettings.Param): JQuery;
<K extends keyof PopupSettings>(behavior: 'setting', name: K, value?: undefined): PopupSettings._Impl[K];
<K extends keyof PopupSettings>(behavior: 'setting', name: K, value: PopupSettings._Impl[K]): JQuery;
(behavior: 'setting', value: PopupSettings): JQuery;
(settings?: PopupSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/popup.html#/settings}
*/
interface PopupSettings extends Pick<PopupSettings._Impl, keyof PopupSettings._Impl> { }
type PopupSettings = PopupSettings.Param;
namespace PopupSettings {
type Param = PopupSettings | object;
type Param = (Pick<_Impl, 'popup'> |
Pick<_Impl, 'exclusive'> |
Pick<_Impl, 'movePopup'> |
Pick<_Impl, 'observeChanges'> |
Pick<_Impl, 'boundary'> |
Pick<_Impl, 'context'> |
Pick<_Impl, 'scrollContext'> |
Pick<_Impl, 'jitter'> |
Pick<_Impl, 'position'> |
Pick<_Impl, 'inline'> |
Pick<_Impl, 'preserve'> |
Pick<_Impl, 'prefer'> |
Pick<_Impl, 'lastResort'> |
Pick<_Impl, 'on'> |
Pick<_Impl, 'delay'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'setFluidWidth'> |
Pick<_Impl, 'hoverable'> |
Pick<_Impl, 'closable'> |
Pick<_Impl, 'addTouchEvents'> |
Pick<_Impl, 'hideOnScroll'> |
Pick<_Impl, 'target'> |
Pick<_Impl, 'distanceAway'> |
Pick<_Impl, 'offset'> |
Pick<_Impl, 'maxSearchDepth'> |
Pick<_Impl, 'onCreate'> |
Pick<_Impl, 'onRemove'> |
Pick<_Impl, 'onShow'> |
Pick<_Impl, 'onVisible'> |
Pick<_Impl, 'onHide'> |
Pick<_Impl, 'onHidden'> |
Pick<_Impl, 'onUnplaceable'> |
Pick<_Impl, 'variation'> |
Pick<_Impl, 'content'> |
Pick<_Impl, 'title'> |
Pick<_Impl, 'html'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Popup Settings
@@ -352,10 +399,12 @@ declare namespace SemanticUI {
}
namespace Popup {
interface DelaySettings extends Pick<DelaySettings._Impl, keyof DelaySettings._Impl> { }
type DelaySettings = DelaySettings.Param;
namespace DelaySettings {
type Param = DelaySettings | object;
type Param = (Pick<_Impl, 'show'> |
Pick<_Impl, 'hide'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
show: number;
@@ -363,10 +412,11 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'popup'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -376,10 +426,16 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = MetadataSettings | object;
type Param = (Pick<_Impl, 'content'> |
Pick<_Impl, 'html'> |
Pick<_Impl, 'offset'> |
Pick<_Impl, 'position'> |
Pick<_Impl, 'title'> |
Pick<_Impl, 'variation'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -409,10 +465,14 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'loading'> |
Pick<_Impl, 'popup'> |
Pick<_Impl, 'position'> |
Pick<_Impl, 'visible'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -434,10 +494,15 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'invalidPosition'> |
Pick<_Impl, 'cannotPlace'> |
Pick<_Impl, 'method'> |
Pick<_Impl, 'noTransition'> |
Pick<_Impl, 'notFound'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_popup_static() {
$.fn.popup.settings.error.method = 'method';
$.fn.popup.settings.error!.method = 'method';
$.fn.popup.settings.namespace = 'namespace';
$.fn.popup.settings.name = 'name';
$.fn.popup.settings.silent = false;
@@ -10,21 +10,22 @@ function test_popup_static() {
function test_popup() {
const selector = '.ui.popup';
$(selector).popup('show') === $();
$(selector).popup('hide') === $();
$(selector).popup('hide all') === $();
$(selector).popup('get popup') === $();
$(selector).popup('change content', '<div></div>') === $();
$(selector).popup('toggle') === $();
$(selector).popup('is visible') === true;
$(selector).popup('is hidden') === true;
$(selector).popup('exists') === true;
$(selector).popup('reposition') === $();
$(selector).popup('set position', 'position') === $();
$(selector).popup('destroy') === $();
$(selector).popup('setting', 'debug', undefined) === false;
$(selector).popup('setting', 'debug') === false;
$(selector).popup('setting', 'debug', true) === $();
$(selector).popup('show'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('hide all'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('get popup'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('change content', '<div></div>'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('is visible'); // $ExpectType boolean
$(selector).popup('is hidden'); // $ExpectType boolean
$(selector).popup('exists'); // $ExpectType boolean
$(selector).popup('reposition'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('set position', 'position'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).popup('setting', 'debug', undefined); // $ExpectType boolean
$(selector).popup('setting', 'debug'); // $ExpectType boolean
$(selector).popup('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).popup('setting', {
namespace: 'namespace',
name: 'name',
@@ -32,7 +33,8 @@ function test_popup() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).popup({
popup: $(),
exclusive: true,
@@ -64,34 +66,36 @@ function test_popup() {
offset: 2,
maxSearchDepth: 10,
onCreate($module) {
this === $();
$module === $();
this; // $ExpectType JQuery<HTMLElement>
$module; // $ExpectType JQuery<HTMLElement>
},
onRemove($module) {
this === $();
$module === $();
this; // $ExpectType JQuery<HTMLElement>
$module; // $ExpectType JQuery<HTMLElement>
},
onShow($module) {
this === $();
$module === $();
this; // $ExpectType JQuery<HTMLElement>
$module; // $ExpectType JQuery<HTMLElement>
return false;
},
onVisible($module) {
this === $();
$module === $();
this; // $ExpectType JQuery<HTMLElement>
$module; // $ExpectType JQuery<HTMLElement>
},
onHide($module) {
this === $();
$module === $();
this; // $ExpectType JQuery<HTMLElement>
$module; // $ExpectType JQuery<HTMLElement>
return false;
},
onHidden($module) {
this === $();
$module === $();
this; // $ExpectType JQuery<HTMLElement>
$module; // $ExpectType JQuery<HTMLElement>
},
onUnplaceable($module) {
this === $();
$module === $();
this; // $ExpectType JQuery<HTMLElement>
$module; // $ExpectType JQuery<HTMLElement>
},
variation: 'variation',
content: 'content',
@@ -121,12 +125,16 @@ function test_popup() {
noTransition: 'noTransition',
notFound: 'notFound'
}
}) === $();
$(selector).popup() === $();
});
$(selector).popup(); // $ExpectType JQuery<HTMLElement>
$(selector).popup('foo'); // $ExpectError
$(selector).popup({ foo: 'bar' }); // $ExpectError
}
import popup = require('semantic-ui-popup');
function test_module() {
popup; // $ExpectType Popup
$.fn.popup = popup;
}
+66 -20
View File
@@ -123,19 +123,44 @@ declare namespace SemanticUI {
*/
(behavior: 'remove error'): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof ProgressSettings>(behavior: 'setting', name: K, value?: undefined): ProgressSettings[K];
<K extends keyof ProgressSettings>(behavior: 'setting', name: K, value: ProgressSettings[K]): JQuery;
(behavior: 'setting', value: ProgressSettings.Param): JQuery;
(settings?: ProgressSettings.Param): JQuery;
<K extends keyof ProgressSettings>(behavior: 'setting', name: K, value?: undefined): ProgressSettings._Impl[K];
<K extends keyof ProgressSettings>(behavior: 'setting', name: K, value: ProgressSettings._Impl[K]): JQuery;
(behavior: 'setting', value: ProgressSettings): JQuery;
(settings?: ProgressSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/progress.html#/settings}
*/
interface ProgressSettings extends Pick<ProgressSettings._Impl, keyof ProgressSettings._Impl> { }
type ProgressSettings = ProgressSettings.Param;
namespace ProgressSettings {
type Param = ProgressSettings | object;
type Param = (Pick<_Impl, 'autoSuccess'> |
Pick<_Impl, 'showActivity'> |
Pick<_Impl, 'limitValues'> |
Pick<_Impl, 'label'> |
Pick<_Impl, 'random'> |
Pick<_Impl, 'precision'> |
Pick<_Impl, 'total'> |
Pick<_Impl, 'value'> |
Pick<_Impl, 'onChange'> |
Pick<_Impl, 'onSuccess'> |
Pick<_Impl, 'onActive'> |
Pick<_Impl, 'onError'> |
Pick<_Impl, 'onWarning'> |
Pick<_Impl, 'text'> |
Pick<_Impl, 'regExp'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Progress Settings
@@ -287,10 +312,12 @@ declare namespace SemanticUI {
}
namespace Progress {
interface RandomSettings extends Pick<RandomSettings._Impl, keyof RandomSettings._Impl> { }
type RandomSettings = RandomSettings.Param;
namespace RandomSettings {
type Param = RandomSettings | object;
type Param = (Pick<_Impl, 'min'> |
Pick<_Impl, 'max'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -304,10 +331,16 @@ declare namespace SemanticUI {
}
}
interface TextSettings extends Pick<TextSettings._Impl, keyof TextSettings._Impl> { }
type TextSettings = TextSettings.Param;
namespace TextSettings {
type Param = TextSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'success'> |
Pick<_Impl, 'warning'> |
Pick<_Impl, 'percent'> |
Pick<_Impl, 'ratio'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -337,10 +370,11 @@ declare namespace SemanticUI {
}
}
interface RegExpSettings extends Pick<RegExpSettings._Impl, keyof RegExpSettings._Impl> { }
type RegExpSettings = RegExpSettings.Param;
namespace RegExpSettings {
type Param = RegExpSettings | object;
type Param = (Pick<_Impl, 'variable'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -350,10 +384,13 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'bar'> |
Pick<_Impl, 'label'> |
Pick<_Impl, 'progress'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -371,10 +408,13 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = MetadataSettings | object;
type Param = (Pick<_Impl, 'percent'> |
Pick<_Impl, 'total'> |
Pick<_Impl, 'value'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -392,10 +432,14 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'success'> |
Pick<_Impl, 'warning'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -417,10 +461,12 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'method'> |
Pick<_Impl, 'nonNumeric'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_progress_static() {
$.fn.progress.settings.error.method = 'method';
$.fn.progress.settings.error!.method = 'method';
$.fn.progress.settings.namespace = 'namespace';
$.fn.progress.settings.name = 'name';
$.fn.progress.settings.silent = false;
@@ -10,39 +10,40 @@ function test_progress_static() {
function test_progress() {
const selector = '.ui.progress';
$(selector).progress('set percent', 10) === $();
$(selector).progress('set progress', 25) === $();
$(selector).progress('increment', 5) === $();
$(selector).progress('decrement', 2) === $();
$(selector).progress('update progress', 45) === $();
$(selector).progress('complete') === $();
$(selector).progress('reset') === $();
$(selector).progress('set total', 100) === $();
$(selector).progress('get text', 'text') === 'text';
$(selector).progress('get normalized value', 20) === 40;
$(selector).progress('get percent') === 22;
$(selector).progress('get value') === 45;
$(selector).progress('get total') === 67;
$(selector).progress('is complete') === false;
$(selector).progress('is success') === false;
$(selector).progress('is warning') === false;
$(selector).progress('is error') === false;
$(selector).progress('is active') === false;
$(selector).progress('set active') === $();
$(selector).progress('set warning') === $();
$(selector).progress('set success') === $();
$(selector).progress('set error') === $();
$(selector).progress('set duration', 4) === $();
$(selector).progress('set label', 'label') === $();
$(selector).progress('set bar label', 'bar label') === $();
$(selector).progress('remove active') === $();
$(selector).progress('remove warning') === $();
$(selector).progress('remove success') === $();
$(selector).progress('remove error') === $();
$(selector).progress('destroy') === $();
$(selector).progress('setting', 'debug', undefined) === false;
$(selector).progress('setting', 'debug') === false;
$(selector).progress('setting', 'debug', true) === $();
$(selector).progress('set percent', 10); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set progress', 25); // $ExpectType JQuery<HTMLElement>
$(selector).progress('increment', 5); // $ExpectType JQuery<HTMLElement>
$(selector).progress('decrement', 2); // $ExpectType JQuery<HTMLElement>
$(selector).progress('update progress', 45); // $ExpectType JQuery<HTMLElement>
$(selector).progress('complete'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('reset'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set total', 100); // $ExpectType JQuery<HTMLElement>
$(selector).progress('get text', 'text'); // $ExpectType string
$(selector).progress('get normalized value', 20); // $ExpectType number
$(selector).progress('get percent'); // $ExpectType number
$(selector).progress('get value'); // $ExpectType number
$(selector).progress('get total'); // $ExpectType number
$(selector).progress('is complete'); // $ExpectType boolean
$(selector).progress('is success'); // $ExpectType boolean
$(selector).progress('is warning'); // $ExpectType boolean
$(selector).progress('is error'); // $ExpectType boolean
$(selector).progress('is active'); // $ExpectType boolean
$(selector).progress('set active'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set warning'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set success'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set error'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set duration', 4); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set label', 'label'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('set bar label', 'bar label'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('remove active'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('remove warning'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('remove success'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('remove error'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).progress('setting', 'debug', undefined); // $ExpectType boolean
$(selector).progress('setting', 'debug'); // $ExpectType boolean
$(selector).progress('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).progress('setting', {
namespace: 'namespace',
name: 'name',
@@ -50,7 +51,8 @@ function test_progress() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).progress({
autoSuccess: false,
showActivity: true,
@@ -64,29 +66,29 @@ function test_progress() {
total: 10,
value: 20,
onChange(percent, value, total) {
this === $();
percent === 10;
value === 20;
total === 30;
this; // $ExpectType JQuery<HTMLElement>
percent; // $ExpectType number
value; // $ExpectType number
total; // $ExpectType number
},
onSuccess(total) {
this === $();
total === 30;
this; // $ExpectType JQuery<HTMLElement>
total; // $ExpectType number
},
onActive(value, total) {
this === $();
value === 20;
total === 30;
this; // $ExpectType JQuery<HTMLElement>
value; // $ExpectType number
total; // $ExpectType number
},
onError(value, total) {
this === $();
value === 20;
total === 30;
this; // $ExpectType JQuery<HTMLElement>
value; // $ExpectType number
total; // $ExpectType number
},
onWarning(value, total) {
this === $();
value === 20;
total === 30;
this; // $ExpectType JQuery<HTMLElement>
value; // $ExpectType number
total; // $ExpectType number
},
text: {
active: 'active',
@@ -119,12 +121,16 @@ function test_progress() {
method: 'method',
nonNumeric: 'nonNumeric'
}
}) === $();
$(selector).progress() === $();
});
$(selector).progress(); // $ExpectType JQuery<HTMLElement>
$(selector).progress('foo'); // $ExpectError
$(selector).progress({ foo: 'bar' }); // $ExpectError
}
import progress = require('semantic-ui-progress');
function test_module() {
progress; // $ExpectType Progress
$.fn.progress = progress;
}
+31 -12
View File
@@ -27,19 +27,33 @@ declare namespace SemanticUI {
*/
(behavior: 'clear rating'): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof RatingSettings>(behavior: 'setting', name: K, value?: undefined): RatingSettings[K];
<K extends keyof RatingSettings>(behavior: 'setting', name: K, value: RatingSettings[K]): JQuery;
(behavior: 'setting', value: RatingSettings.Param): JQuery;
(settings?: RatingSettings.Param): JQuery;
<K extends keyof RatingSettings>(behavior: 'setting', name: K, value?: undefined): RatingSettings._Impl[K];
<K extends keyof RatingSettings>(behavior: 'setting', name: K, value: RatingSettings._Impl[K]): JQuery;
(behavior: 'setting', value: RatingSettings): JQuery;
(settings?: RatingSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/rating.html#/settings}
*/
interface RatingSettings extends Pick<RatingSettings._Impl, keyof RatingSettings._Impl> { }
type RatingSettings = RatingSettings.Param;
namespace RatingSettings {
type Param = RatingSettings | object;
type Param = (Pick<_Impl, 'initialRating'> |
Pick<_Impl, 'fireOnInit'> |
Pick<_Impl, 'clearable'> |
Pick<_Impl, 'interactive'> |
Pick<_Impl, 'onRate'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Rating Settings
@@ -134,10 +148,11 @@ declare namespace SemanticUI {
}
namespace Rating {
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'icon'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -147,10 +162,13 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'hover'> |
Pick<_Impl, 'loading'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -168,10 +186,11 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'action'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_rating_static() {
$.fn.rating.settings.error.action = 'action';
$.fn.rating.settings.error!.action = 'action';
$.fn.rating.settings.namespace = 'namespace';
$.fn.rating.settings.name = 'name';
$.fn.rating.settings.silent = false;
@@ -10,15 +10,16 @@ function test_rating_static() {
function test_rating() {
const selector = '.ui.rating';
$(selector).rating('set rating', 3) === $();
$(selector).rating('get rating') === 4;
$(selector).rating('disable') === $();
$(selector).rating('enable') === $();
$(selector).rating('clear rating') === $();
$(selector).rating('destroy') === $();
$(selector).rating('setting', 'debug', undefined) === false;
$(selector).rating('setting', 'debug') === false;
$(selector).rating('setting', 'debug', true) === $();
$(selector).rating('set rating', 3); // $ExpectType JQuery<HTMLElement>
$(selector).rating('get rating'); // $ExpectType number
$(selector).rating('disable'); // $ExpectType JQuery<HTMLElement>
$(selector).rating('enable'); // $ExpectType JQuery<HTMLElement>
$(selector).rating('clear rating'); // $ExpectType JQuery<HTMLElement>
$(selector).rating('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).rating('setting', 'debug', undefined); // $ExpectType boolean
$(selector).rating('setting', 'debug'); // $ExpectType boolean
$(selector).rating('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).rating('setting', {
namespace: 'namespace',
name: 'name',
@@ -26,15 +27,16 @@ function test_rating() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).rating({
initialRating: 0,
fireOnInit: false,
clearable: false,
interactive: true,
onRate(value) {
this === $();
value === 3;
this; // $ExpectType JQuery<HTMLElement>
value; // $ExpectType number
},
selector: {
icon: '.icon'
@@ -47,12 +49,16 @@ function test_rating() {
error: {
action: 'action'
}
}) === $();
$(selector).rating() === $();
});
$(selector).rating(); // $ExpectType JQuery<HTMLElement>
$(selector).rating('foo'); // $ExpectError
$(selector).rating({ foo: 'bar' }); // $ExpectError
}
import rating = require('semantic-ui-rating');
function test_module() {
rating; // $ExpectType Rating
$.fn.rating = rating;
}
+89 -20
View File
@@ -94,19 +94,52 @@ declare namespace SemanticUI {
* Removes all events
*/
(behavior: 'destroy'): JQuery;
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value?: undefined): SearchSettings[K];
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value: SearchSettings[K]): JQuery;
(behavior: 'setting', value: SearchSettings.Param): JQuery;
(settings?: SearchSettings.Param): JQuery;
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value?: undefined): SearchSettings._Impl[K];
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value: SearchSettings._Impl[K]): JQuery;
(behavior: 'setting', value: SearchSettings): JQuery;
(settings?: SearchSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/search.html#/settings}
*/
interface SearchSettings extends Pick<SearchSettings._Impl, keyof SearchSettings._Impl> { }
type SearchSettings = SearchSettings.Param;
namespace SearchSettings {
type Param = SearchSettings | object;
type Param = (Pick<_Impl, 'apiSettings'> |
Pick<_Impl, 'minCharacters'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'maxResults'> |
Pick<_Impl, 'cache'> |
Pick<_Impl, 'source'> |
Pick<_Impl, 'selectFirstResult'> |
Pick<_Impl, 'showNoResults'> |
Pick<_Impl, 'searchFullText'> |
Pick<_Impl, 'fields'> |
Pick<_Impl, 'searchFields'> |
Pick<_Impl, 'hideDelay'> |
Pick<_Impl, 'searchDelay'> |
Pick<_Impl, 'easing'> |
Pick<_Impl, 'onSelect'> |
Pick<_Impl, 'onResultsAdd'> |
Pick<_Impl, 'onSearchQuery'> |
Pick<_Impl, 'onResults'> |
Pick<_Impl, 'onResultsOpen'> |
Pick<_Impl, 'onResultsClose'> |
Pick<_Impl, 'templates'> |
Pick<_Impl, 'regExp'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Behavior
@@ -306,10 +339,21 @@ declare namespace SemanticUI {
}
namespace Search {
interface FieldsSettings extends Pick<FieldsSettings._Impl, keyof FieldsSettings._Impl> { }
type FieldsSettings = FieldsSettings.Param;
namespace FieldsSettings {
type Param = FieldsSettings | object;
type Param = (Pick<_Impl, 'categories'> |
Pick<_Impl, 'categoryName'> |
Pick<_Impl, 'categoryResults'> |
Pick<_Impl, 'description'> |
Pick<_Impl, 'image'> |
Pick<_Impl, 'price'> |
Pick<_Impl, 'results'> |
Pick<_Impl, 'title'> |
Pick<_Impl, 'action'> |
Pick<_Impl, 'actionText'> |
Pick<_Impl, 'actionURL'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -381,10 +425,14 @@ declare namespace SemanticUI {
}
}
interface TemplatesSettings extends Pick<TemplatesSettings._Impl, keyof TemplatesSettings._Impl> { }
type TemplatesSettings = TemplatesSettings.Param;
namespace TemplatesSettings {
type Param = TemplatesSettings | object;
type Param = (Pick<_Impl, 'escape'> |
Pick<_Impl, 'message'> |
Pick<_Impl, 'category'> |
Pick<_Impl, 'standard'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
escape(string: string): string;
@@ -394,10 +442,12 @@ declare namespace SemanticUI {
}
}
interface RegExpSettings extends Pick<RegExpSettings._Impl, keyof RegExpSettings._Impl> { }
type RegExpSettings = RegExpSettings.Param;
namespace RegExpSettings {
type Param = RegExpSettings | object;
type Param = (Pick<_Impl, 'escape'> |
Pick<_Impl, 'beginsWith'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -411,10 +461,15 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'prompt'> |
Pick<_Impl, 'searchButton'> |
Pick<_Impl, 'results'> |
Pick<_Impl, 'category'> |
Pick<_Impl, 'result'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -440,10 +495,12 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = MetadataSettings | object;
type Param = (Pick<_Impl, 'cache'> |
Pick<_Impl, 'results'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -457,10 +514,15 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'empty'> |
Pick<_Impl, 'focus'> |
Pick<_Impl, 'loading'> |
Pick<_Impl, 'pressed'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -486,10 +548,17 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'source'> |
Pick<_Impl, 'noResults'> |
Pick<_Impl, 'logging'> |
Pick<_Impl, 'noTemplate'> |
Pick<_Impl, 'serverError'> |
Pick<_Impl, 'maxResults'> |
Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_search_static() {
$.fn.search.settings.error.method = 'method';
$.fn.search.settings.error!.method = 'method';
$.fn.search.settings.namespace = 'namespace';
$.fn.search.settings.name = 'name';
$.fn.search.settings.silent = false;
@@ -10,31 +10,32 @@ function test_search_static() {
function test_search() {
const selector = '.ui.search';
$(selector).search('query', () => { }) === $();
$(selector).search('display message', 'text', 'type') === $();
$(selector).search('cancel query') === $();
$(selector).search('search local', 'query') === $();
$(selector).search('has minimum characters') === true;
$(selector).search('search remote', 'query', () => { }) === $();
$(selector).search('search object', 'query', {}, ['searchField']) === {};
$(selector).search('cancel query') === $();
$(selector).search('is focused') === false;
$(selector).search('is visible') === true;
$(selector).search('is empty') === false;
$(selector).search('get value') === {};
$(selector).search('get result', 'value') === {};
$(selector).search('set value', 'value') === $();
$(selector).search('read cache', 'query') === $();
$(selector).search('clear cache', 'query') === $();
$(selector).search('write cache', 'query') === $();
$(selector).search('add results', 'html') === $();
$(selector).search('show results', () => { }) === $();
$(selector).search('hide results', () => { }) === $();
$(selector).search('generate results', {}) === $();
$(selector).search('destroy') === $();
$(selector).search('setting', 'debug', undefined) === false;
$(selector).search('setting', 'debug') === false;
$(selector).search('setting', 'debug', true) === $();
$(selector).search('query', () => { }); // $ExpectType JQuery<HTMLElement>
$(selector).search('display message', 'text', 'type'); // $ExpectType JQuery<HTMLElement>
$(selector).search('cancel query'); // $ExpectType JQuery<HTMLElement>
$(selector).search('search local', 'query'); // $ExpectType JQuery<HTMLElement>
$(selector).search('has minimum characters'); // $ExpectType boolean
$(selector).search('search remote', 'query', () => { }); // $ExpectType JQuery<HTMLElement>
$(selector).search('search object', 'query', {}, ['searchField']); // $ExpectType any
$(selector).search('cancel query'); // $ExpectType JQuery<HTMLElement>
$(selector).search('is focused'); // $ExpectType boolean
$(selector).search('is visible'); // $ExpectType boolean
$(selector).search('is empty'); // $ExpectType boolean
$(selector).search('get value'); // $ExpectType any
$(selector).search('get result', 'value'); // $ExpectType any
$(selector).search('set value', 'value'); // $ExpectType JQuery<HTMLElement>
$(selector).search('read cache', 'query'); // $ExpectType JQuery<HTMLElement>
$(selector).search('clear cache', 'query'); // $ExpectType JQuery<HTMLElement>
$(selector).search('write cache', 'query'); // $ExpectType JQuery<HTMLElement>
$(selector).search('add results', 'html'); // $ExpectType JQuery<HTMLElement>
$(selector).search('show results', () => { }); // $ExpectType JQuery<HTMLElement>
$(selector).search('hide results', () => { }); // $ExpectType JQuery<HTMLElement>
$(selector).search('generate results', {}); // $ExpectType JQuery<HTMLElement>
$(selector).search('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).search('setting', 'debug', undefined); // $ExpectType boolean
$(selector).search('setting', 'debug'); // $ExpectType boolean
$(selector).search('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).search('setting', {
namespace: 'namespace',
name: 'name',
@@ -42,7 +43,8 @@ function test_search() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).search({
apiSettings: {
on: 'on',
@@ -62,56 +64,58 @@ function test_search() {
urlData: false,
response: false,
responseAsync(settings, callback) {
settings === ({} as SemanticUI.ApiSettings);
callback === ((response: any) => { });
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
mockResponse: false,
mockResponseAsync(settings, callback) {
settings === ({} as SemanticUI.ApiSettings);
callback === ((response: any) => { });
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
method: 'post',
dataType: 'xml',
data: {},
beforeSend(settings) {
settings === ({} as SemanticUI.ApiSettings);
settings; // $ExpectType Param
},
beforeXHR(xhrObject) {
xhrObject === ({} as JQueryXHR);
xhrObject; // $ExpectType jqXHR<any>
},
onRequest(promise, xhr) {
promise === ({} as JQueryDeferred<any>);
xhr === ({} as JQueryXHR);
promise; // $ExpectType Deferred<any, any, any>
xhr; // $ExpectType jqXHR<any>
},
onResponse(response) {
response === ({} as any);
response; // $ExpectType any
},
successTest(response) {
return response === ({} as any);
response; // $ExpectType any
return false;
},
onSuccess(response, element, xhr) {
response === ({} as any);
element === $();
xhr === ({} as JQueryXHR);
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onComplete(response, element, xhr) {
response === ({} as any);
element === $();
xhr === ({} as JQueryXHR);
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onFailure(response, element) {
response === ({} as any);
element === $();
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
},
onError(errorMessage, element, xhr) {
errorMessage === '';
element === $();
xhr === ({} as JQueryXHR);
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onAbort(errorMessage, element, xhr) {
errorMessage === '';
element === $();
xhr === ({} as JQueryXHR);
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
regExp: {
required: /{\$*[A-z0-9]+}/g,
@@ -175,41 +179,52 @@ function test_search() {
searchDelay: 10,
easing: 'easeOutExpo',
onSelect(result, response) {
this === $();
result === {};
response === {};
this; // $ExpectType JQuery<HTMLElement>
result; // $ExpectType any
response; // $ExpectType any
return false;
},
onResultsAdd(html) {
this === $();
html === 'html';
this; // $ExpectType JQuery<HTMLElement>
html; // $ExpectType string
return false;
},
onSearchQuery(query) {
this === $();
query === 'query';
this; // $ExpectType JQuery<HTMLElement>
query; // $ExpectType string
},
onResults(response) {
this === $();
response === {};
this; // $ExpectType JQuery<HTMLElement>
response; // $ExpectType any
},
onResultsOpen() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onResultsClose() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
templates: {
escape(string) {
return string;
string; // $ExpectType string
return 'escape';
},
message(message, type) {
return message + type;
message; // $ExpectType string
type; // $ExpectType string
return 'message';
},
category(response) {
response; // $ExpectType any
return 'category';
},
standard(response) {
response; // $ExpectType any
return 'standard';
}
},
@@ -244,12 +259,16 @@ function test_search() {
maxResults: 'maxResults',
method: 'method'
}
}) === $();
$(selector).search() === $();
});
$(selector).search(); // $ExpectType JQuery<HTMLElement>
$(selector).search('foo'); // $ExpectError
$(selector).search({ foo: 'bar' }); // $ExpectError
}
import search = require('semantic-ui-search');
function test_module() {
search; // $ExpectType Search
$.fn.search = search;
}
+34 -12
View File
@@ -83,19 +83,33 @@ declare namespace SemanticUI {
*/
(behavior: 'get transform down'): Shape.Translation;
(behavior: 'destroy'): JQuery;
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value?: undefined): ShapeSettings[K];
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value: ShapeSettings[K]): JQuery;
(behavior: 'setting', value: ShapeSettings.Param): JQuery;
(settings?: ShapeSettings.Param): JQuery;
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value?: undefined): ShapeSettings._Impl[K];
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value: ShapeSettings._Impl[K]): JQuery;
(behavior: 'setting', value: ShapeSettings): JQuery;
(settings?: ShapeSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/shape.html#/settings}
*/
interface ShapeSettings extends Pick<ShapeSettings._Impl, keyof ShapeSettings._Impl> { }
type ShapeSettings = ShapeSettings.Param;
namespace ShapeSettings {
type Param = ShapeSettings | object;
type Param = (Pick<_Impl, 'duration'> |
Pick<_Impl, 'width'> |
Pick<_Impl, 'height'> |
Pick<_Impl, 'beforeChange'> |
Pick<_Impl, 'onChange'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Shape Settings
@@ -198,10 +212,12 @@ declare namespace SemanticUI {
transform: string;
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'sides'> |
Pick<_Impl, 'side'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -215,10 +231,14 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'animating'> |
Pick<_Impl, 'hidden'> |
Pick<_Impl, 'loading'> |
Pick<_Impl, 'active'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -240,10 +260,12 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'side'> |
Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_shape_static() {
$.fn.shape.settings.error.method = 'method';
$.fn.shape.settings.error!.method = 'method';
$.fn.shape.settings.namespace = 'namespace';
$.fn.shape.settings.name = 'name';
$.fn.shape.settings.silent = false;
@@ -10,29 +10,30 @@ function test_shape_static() {
function test_shape() {
const selector = '.ui.shape';
$(selector).shape('flip up') === $();
$(selector).shape('flip down') === $();
$(selector).shape('flip right') === $();
$(selector).shape('flip left') === $();
$(selector).shape('flip over') === $();
$(selector).shape('flip back') === $();
$(selector).shape('set next side', $()) === $();
$(selector).shape('is animating') === false;
$(selector).shape('reset') === $();
$(selector).shape('queue', 'animation') === $();
$(selector).shape('repaint') === $();
$(selector).shape('set default side') === $();
$(selector).shape('set stage size') === $();
$(selector).shape('refresh') === $();
$(selector).shape('get transform down') === { transform: 'transform' };
$(selector).shape('get transform left') === { transform: 'transform' };
$(selector).shape('get transform right') === { transform: 'transform' };
$(selector).shape('get transform up') === { transform: 'transform' };
$(selector).shape('get transform down') === { transform: 'transform' };
$(selector).shape('destroy') === $();
$(selector).shape('setting', 'debug', undefined) === false;
$(selector).shape('setting', 'debug') === false;
$(selector).shape('setting', 'debug', true) === $();
$(selector).shape('flip up'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('flip down'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('flip right'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('flip left'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('flip over'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('flip back'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('set next side', $()); // $ExpectType JQuery<HTMLElement>
$(selector).shape('is animating'); // $ExpectType boolean
$(selector).shape('reset'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('queue', 'animation'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('repaint'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('set default side'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('set stage size'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('refresh'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('get transform down'); // $ExpectType Translation
$(selector).shape('get transform left'); // $ExpectType Translation
$(selector).shape('get transform right'); // $ExpectType Translation
$(selector).shape('get transform up'); // $ExpectType Translation
$(selector).shape('get transform down'); // $ExpectType Translation
$(selector).shape('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).shape('setting', 'debug', undefined); // $ExpectType boolean
$(selector).shape('setting', 'debug'); // $ExpectType boolean
$(selector).shape('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).shape('setting', {
namespace: 'namespace',
name: 'name',
@@ -40,16 +41,17 @@ function test_shape() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).shape({
duration: 700,
width: 'next',
height: 200,
beforeChange() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onChange() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
selector: {
sides: 'sides',
@@ -65,12 +67,16 @@ function test_shape() {
side: 'side',
method: 'method'
}
}) === $();
$(selector).shape() === $();
});
$(selector).shape(); // $ExpectType JQuery<HTMLElement>
$(selector).shape('foo'); // $ExpectError
$(selector).shape({ foo: 'bar' }); // $ExpectError
}
import shape = require('semantic-ui-shape');
function test_module() {
shape; // $ExpectType Shape
$.fn.shape = shape;
}
+80 -20
View File
@@ -55,19 +55,47 @@ declare namespace SemanticUI {
*/
(behavior: 'get transition event'): string;
(behavior: 'destroy'): JQuery;
<K extends keyof SidebarSettings>(behavior: 'setting', name: K, value?: undefined): SidebarSettings[K];
<K extends keyof SidebarSettings>(behavior: 'setting', name: K, value: SidebarSettings[K]): JQuery;
(behavior: 'setting', value: SidebarSettings.Param): JQuery;
(settings?: SidebarSettings.Param): JQuery;
<K extends keyof SidebarSettings>(behavior: 'setting', name: K, value?: undefined): SidebarSettings._Impl[K];
<K extends keyof SidebarSettings>(behavior: 'setting', name: K, value: SidebarSettings._Impl[K]): JQuery;
(behavior: 'setting', value: SidebarSettings): JQuery;
(settings?: SidebarSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/sidebar.html#/settings}
*/
interface SidebarSettings extends Pick<SidebarSettings._Impl, keyof SidebarSettings._Impl> { }
type SidebarSettings = SidebarSettings.Param;
namespace SidebarSettings {
type Param = SidebarSettings | object;
type Param = (Pick<_Impl, 'context'> |
Pick<_Impl, 'exclusive'> |
Pick<_Impl, 'closable'> |
Pick<_Impl, 'dimPage'> |
Pick<_Impl, 'scrollLock'> |
Pick<_Impl, 'returnScroll'> |
Pick<_Impl, 'delaySetup'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'mobileTransition'> |
Pick<_Impl, 'defaultTransition'> |
Pick<_Impl, 'useLegacy'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'easing'> |
Pick<_Impl, 'onVisible'> |
Pick<_Impl, 'onShow'> |
Pick<_Impl, 'onChange'> |
Pick<_Impl, 'onHide'> |
Pick<_Impl, 'onHidden'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'regExp'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Behavior
@@ -236,20 +264,26 @@ declare namespace SemanticUI {
}
namespace Sidebar {
interface DefaultTransitionSettings extends Pick<DefaultTransitionSettings._Impl, keyof DefaultTransitionSettings._Impl> { }
type DefaultTransitionSettings = DefaultTransitionSettings.Param;
namespace DefaultTransitionSettings {
type Param = DefaultTransitionSettings | object;
type Param = (Pick<_Impl, 'computer'> |
Pick<_Impl, 'mobile'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
computer: ComputerSettings;
mobile: MobileSettings;
}
interface ComputerSettings extends Pick<ComputerSettings._Impl, keyof ComputerSettings._Impl> { }
type ComputerSettings = ComputerSettings.Param;
namespace ComputerSettings {
type Param = ComputerSettings | object;
type Param = (Pick<_Impl, 'left'> |
Pick<_Impl, 'right'> |
Pick<_Impl, 'top'> |
Pick<_Impl, 'bottom'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -271,10 +305,14 @@ declare namespace SemanticUI {
}
}
interface MobileSettings extends Pick<MobileSettings._Impl, keyof MobileSettings._Impl> { }
type MobileSettings = MobileSettings.Param;
namespace MobileSettings {
type Param = MobileSettings | object;
type Param = (Pick<_Impl, 'left'> |
Pick<_Impl, 'right'> |
Pick<_Impl, 'top'> |
Pick<_Impl, 'bottom'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -297,10 +335,21 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'active'> |
Pick<_Impl, 'animating'> |
Pick<_Impl, 'dimmed'> |
Pick<_Impl, 'ios'> |
Pick<_Impl, 'pushable'> |
Pick<_Impl, 'pushed'> |
Pick<_Impl, 'right'> |
Pick<_Impl, 'top'> |
Pick<_Impl, 'left'> |
Pick<_Impl, 'bottom'> |
Pick<_Impl, 'visible'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -350,10 +399,12 @@ declare namespace SemanticUI {
}
}
interface RegExpSettings extends Pick<RegExpSettings._Impl, keyof RegExpSettings._Impl> { }
type RegExpSettings = RegExpSettings.Param;
namespace RegExpSettings {
type Param = RegExpSettings | object;
type Param = (Pick<_Impl, 'ios'> |
Pick<_Impl, 'mobile'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -367,10 +418,14 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'fixed'> |
Pick<_Impl, 'omitted'> |
Pick<_Impl, 'pusher'> |
Pick<_Impl, 'sidebar'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -392,10 +447,15 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'method'> |
Pick<_Impl, 'pusher'> |
Pick<_Impl, 'movedSidebar'> |
Pick<_Impl, 'overlay'> |
Pick<_Impl, 'notFound'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_sidebar_static() {
$.fn.sidebar.settings.error.method = 'method';
$.fn.sidebar.settings.error!.method = 'method';
$.fn.sidebar.settings.namespace = 'namespace';
$.fn.sidebar.settings.name = 'name';
$.fn.sidebar.settings.silent = false;
@@ -10,22 +10,23 @@ function test_sidebar_static() {
function test_sidebar() {
const selector = '.ui.sidebar';
$(selector).sidebar('attach events', $(), 'toggle') === $();
$(selector).sidebar('show') === $();
$(selector).sidebar('hide') === $();
$(selector).sidebar('toggle') === $();
$(selector).sidebar('is visible') === false;
$(selector).sidebar('is hidden') === true;
$(selector).sidebar('push page') === $();
$(selector).sidebar('get direction') === 'top';
$(selector).sidebar('pull page') === $();
$(selector).sidebar('add body CSS') === $();
$(selector).sidebar('remove body CSS') === $();
$(selector).sidebar('get transition event') === 'transition';
$(selector).sidebar('destroy') === $();
$(selector).sidebar('setting', 'debug', undefined) === false;
$(selector).sidebar('setting', 'debug') === false;
$(selector).sidebar('setting', 'debug', true) === $();
$(selector).sidebar('attach events', $(), 'toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('show'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('is visible'); // $ExpectType boolean
$(selector).sidebar('is hidden'); // $ExpectType boolean
$(selector).sidebar('push page'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('get direction'); // $ExpectType string
$(selector).sidebar('pull page'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('add body CSS'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('remove body CSS'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('get transition event'); // $ExpectType string
$(selector).sidebar('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('setting', 'debug', undefined); // $ExpectType boolean
$(selector).sidebar('setting', 'debug'); // $ExpectType boolean
$(selector).sidebar('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).sidebar('setting', {
namespace: 'namespace',
name: 'name',
@@ -33,7 +34,8 @@ function test_sidebar() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).sidebar({
context: $(),
exclusive: false,
@@ -62,19 +64,19 @@ function test_sidebar() {
duration: 20,
easing: 'easeInOutQuint',
onVisible() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onShow() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onChange() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onHide() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onHidden() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
className: {
active: 'active',
@@ -107,12 +109,16 @@ function test_sidebar() {
overlay: 'overlay',
notFound: 'notFound'
}
}) === $();
$(selector).sidebar() === $();
});
$(selector).sidebar(); // $ExpectType JQuery<HTMLElement>
$(selector).sidebar('foo'); // $ExpectError
$(selector).sidebar({ foo: 'bar' }); // $ExpectError
}
import sidebar = require('semantic-ui-sidebar');
function test_module() {
sidebar; // $ExpectType Sidebar
$.fn.sidebar = sidebar;
}
+22 -8
View File
@@ -11,16 +11,25 @@ declare namespace SemanticUI {
settings: SiteSettings;
(behavior: 'destroy'): JQuery;
<K extends keyof SiteSettings>(behavior: 'setting', name: K, value?: undefined): SiteSettings[K];
<K extends keyof SiteSettings>(behavior: 'setting', name: K, value: SiteSettings[K]): JQuery;
(behavior: 'setting', value: SiteSettings.Param): JQuery;
(settings?: SiteSettings.Param): JQuery;
<K extends keyof SiteSettings>(behavior: 'setting', name: K, value?: undefined): SiteSettings._Impl[K];
<K extends keyof SiteSettings>(behavior: 'setting', name: K, value: SiteSettings._Impl[K]): JQuery;
(behavior: 'setting', value: SiteSettings): JQuery;
(settings?: SiteSettings): JQuery;
}
interface SiteSettings extends Pick<SiteSettings._Impl, keyof SiteSettings._Impl> { }
type SiteSettings = SiteSettings.Param;
namespace SiteSettings {
type Param = SiteSettings | object;
type Param = (Pick<_Impl, 'modules'> |
Pick<_Impl, 'siteNamespace'> |
Pick<_Impl, 'namespaceStub'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
modules: string[];
@@ -68,10 +77,15 @@ declare namespace SemanticUI {
}
namespace Site {
interface NamespaceStubSettings extends Pick<NamespaceStubSettings._Impl, keyof NamespaceStubSettings._Impl> { }
type NamespaceStubSettings = NamespaceStubSettings.Param;
namespace NamespaceStubSettings {
type Param = NamespaceStubSettings | object;
type Param = (Pick<_Impl, 'cache'> |
Pick<_Impl, 'config'> |
Pick<_Impl, 'sections'> |
Pick<_Impl, 'section'> |
Pick<_Impl, 'utilities'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
cache: any;
@@ -16,10 +16,11 @@ function test_site_static() {
function test_site() {
const selector = '.ui.site';
$(selector).site('destroy') === $();
$(selector).site('setting', 'debug', undefined) === false;
$(selector).site('setting', 'debug') === false;
$(selector).site('setting', 'debug', true) === $();
$(selector).site('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).site('setting', 'debug', undefined); // $ExpectType boolean
$(selector).site('setting', 'debug'); // $ExpectType boolean
$(selector).site('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).site('setting', {
namespace: 'namespace',
name: 'name',
@@ -27,7 +28,8 @@ function test_site() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).site({
modules: [
'module1',
@@ -41,12 +43,16 @@ function test_site() {
section: {},
utilities: {}
}
}) === $();
$(selector).site() === $();
});
$(selector).site(); // $ExpectType JQuery<HTMLElement>
$(selector).site('foo'); // $ExpectError
$(selector).site({ foo: 'bar' }); // $ExpectError
}
import site = require('semantic-ui-site');
function test_module() {
site; // $ExpectType Site
$.fn.site = site;
}
+41 -10
View File
@@ -11,19 +11,40 @@ declare namespace SemanticUI {
*/
(behavior: 'refresh'): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof StickySettings>(behavior: 'setting', name: K, value?: undefined): StickySettings[K];
<K extends keyof StickySettings>(behavior: 'setting', name: K, value: StickySettings[K]): JQuery;
(behavior: 'setting', value: StickySettings.Param): JQuery;
(settings?: StickySettings.Param): JQuery;
<K extends keyof StickySettings>(behavior: 'setting', name: K, value?: undefined): StickySettings._Impl[K];
<K extends keyof StickySettings>(behavior: 'setting', name: K, value: StickySettings._Impl[K]): JQuery;
(behavior: 'setting', value: StickySettings): JQuery;
(settings?: StickySettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/sticky.html#/settings}
*/
interface StickySettings extends Pick<StickySettings._Impl, keyof StickySettings._Impl> { }
type StickySettings = StickySettings.Param;
namespace StickySettings {
type Param = StickySettings | object;
type Param = (Pick<_Impl, 'pushing'> |
Pick<_Impl, 'jitter'> |
Pick<_Impl, 'observeChanges'> |
Pick<_Impl, 'context'> |
Pick<_Impl, 'scrollContext'> |
Pick<_Impl, 'offset'> |
Pick<_Impl, 'bottomOffset'> |
Pick<_Impl, 'onReposition'> |
Pick<_Impl, 'onScroll'> |
Pick<_Impl, 'onStick'> |
Pick<_Impl, 'onUnstick'> |
Pick<_Impl, 'onTop'> |
Pick<_Impl, 'onBottom'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Sticky Settings
@@ -158,10 +179,15 @@ declare namespace SemanticUI {
}
namespace Sticky {
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'bound'> |
Pick<_Impl, 'fixed'> |
Pick<_Impl, 'supported'> |
Pick<_Impl, 'top'> |
Pick<_Impl, 'bottom'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -187,10 +213,15 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'container'> |
Pick<_Impl, 'visible'> |
Pick<_Impl, 'method'> |
Pick<_Impl, 'invalidContext'> |
Pick<_Impl, 'elementSize'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_sticky_static() {
$.fn.sticky.settings.error.method = 'method';
$.fn.sticky.settings.error!.method = 'method';
$.fn.sticky.settings.namespace = 'namespace';
$.fn.sticky.settings.name = 'name';
$.fn.sticky.settings.silent = false;
@@ -10,11 +10,12 @@ function test_sticky_static() {
function test_sticky() {
const selector = '.ui.sticky';
$(selector).sticky('refresh') === $();
$(selector).sticky('destroy') === $();
$(selector).sticky('setting', 'debug', undefined) === false;
$(selector).sticky('setting', 'debug') === false;
$(selector).sticky('setting', 'debug', true) === $();
$(selector).sticky('refresh'); // $ExpectType JQuery<HTMLElement>
$(selector).sticky('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).sticky('setting', 'debug', undefined); // $ExpectType boolean
$(selector).sticky('setting', 'debug'); // $ExpectType boolean
$(selector).sticky('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).sticky('setting', {
namespace: 'namespace',
name: 'name',
@@ -22,7 +23,8 @@ function test_sticky() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).sticky({
pushing: false,
jitter: 4,
@@ -32,22 +34,22 @@ function test_sticky() {
offset: 1,
bottomOffset: 200,
onReposition() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onScroll() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onStick() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onUnstick() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onTop() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onBottom() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
className: {
bound: 'bound',
@@ -63,12 +65,16 @@ function test_sticky() {
invalidContext: 'invalidContext',
elementSize: 'elementSize'
}
}) === $();
$(selector).sticky() === $();
});
$(selector).sticky(); // $ExpectType JQuery<HTMLElement>
$(selector).sticky('foo'); // $ExpectError
$(selector).sticky({ foo: 'bar' }); // $ExpectError
}
import sticky = require('semantic-ui-sticky');
function test_module() {
sticky; // $ExpectType Sticky
$.fn.sticky = sticky;
}
+61 -16
View File
@@ -40,19 +40,49 @@ declare namespace SemanticUI {
*/
(behavior: 'cache remove', path: string): JQuery;
(behavior: 'destroy'): JQuery;
<K extends keyof TabSettings>(behavior: 'setting', name: K, value?: undefined): TabSettings[K];
<K extends keyof TabSettings>(behavior: 'setting', name: K, value: TabSettings[K]): JQuery;
(behavior: 'setting', value: TabSettings.Param): JQuery;
(settings?: TabSettings.Param): JQuery;
<K extends keyof TabSettings>(behavior: 'setting', name: K, value?: undefined): TabSettings._Impl[K];
<K extends keyof TabSettings>(behavior: 'setting', name: K, value: TabSettings._Impl[K]): JQuery;
(behavior: 'setting', value: TabSettings): JQuery;
(settings?: TabSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/tab.html#/settings}
*/
interface TabSettings extends Pick<TabSettings._Impl, keyof TabSettings._Impl> { }
type TabSettings = TabSettings.Param;
namespace TabSettings {
type Param = TabSettings | object;
type Param = (Pick<_Impl, 'auto'> |
Pick<_Impl, 'deactivate'> |
Pick<_Impl, 'history'> |
Pick<_Impl, 'ignoreFirstLoad'> |
Pick<_Impl, 'evaluateScripts'> |
Pick<_Impl, 'alwaysRefresh'> |
Pick<_Impl, 'cacheType'> |
Pick<_Impl, 'cache'> |
Pick<_Impl, 'apiSettings'> |
Pick<_Impl, 'historyType'> |
Pick<_Impl, 'path'> |
Pick<_Impl, 'context'> |
Pick<_Impl, 'childrenOnly'> |
Pick<_Impl, 'maxDepth'> |
Pick<_Impl, 'loadOnce'> |
Pick<_Impl, 'onFirstLoad'> |
Pick<_Impl, 'onLoad'> |
Pick<_Impl, 'onRequest'> |
Pick<_Impl, 'onVisible'> |
Pick<_Impl, 'templates'> |
Pick<_Impl, 'selector'> |
Pick<_Impl, 'metadata'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Tab Settings
@@ -249,10 +279,11 @@ declare namespace SemanticUI {
}
namespace Tab {
interface TemplatesSettings extends Pick<TemplatesSettings._Impl, keyof TemplatesSettings._Impl> { }
type TemplatesSettings = TemplatesSettings.Param;
namespace TemplatesSettings {
type Param = TemplatesSettings | object;
type Param = (Pick<_Impl, 'determineTitle'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -262,10 +293,12 @@ declare namespace SemanticUI {
}
}
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
type SelectorSettings = SelectorSettings.Param;
namespace SelectorSettings {
type Param = SelectorSettings | object;
type Param = (Pick<_Impl, 'tabs'> |
Pick<_Impl, 'parent'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -279,10 +312,13 @@ declare namespace SemanticUI {
}
}
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
type MetadataSettings = MetadataSettings.Param;
namespace MetadataSettings {
type Param = MetadataSettings | object;
type Param = (Pick<_Impl, 'tab'> |
Pick<_Impl, 'loaded'> |
Pick<_Impl, 'promise'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -300,10 +336,12 @@ declare namespace SemanticUI {
}
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'loading'> |
Pick<_Impl, 'active'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -317,10 +355,17 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'api'> |
Pick<_Impl, 'method'> |
Pick<_Impl, 'missingTab'> |
Pick<_Impl, 'noContent'> |
Pick<_Impl, 'path'> |
Pick<_Impl, 'recursion'> |
Pick<_Impl, 'state'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
+61 -52
View File
@@ -1,5 +1,5 @@
function test_tab_static() {
$.fn.tab.settings.error.method = 'method';
$.fn.tab.settings.error!.method = 'method';
$.fn.tab.settings.namespace = 'namespace';
$.fn.tab.settings.name = 'name';
$.fn.tab.settings.silent = false;
@@ -10,17 +10,18 @@ function test_tab_static() {
function test_tab() {
const selector = '.ui.tab';
$(selector).tab('change tab', 'path') === $();
$(selector).tab('set state', 'path') === $();
$(selector).tab('get path') === 'path';
$(selector).tab('is tab') === false;
$(selector).tab('cache read', 'path') === false;
$(selector).tab('cache add', 'path', 'html') === $();
$(selector).tab('cache remove', 'path') === $();
$(selector).tab('destroy') === $();
$(selector).tab('setting', 'debug', undefined) === false;
$(selector).tab('setting', 'debug') === false;
$(selector).tab('setting', 'debug', true) === $();
$(selector).tab('change tab', 'path'); // $ExpectType JQuery<HTMLElement>
$(selector).tab('set state', 'path'); // $ExpectType JQuery<HTMLElement>
$(selector).tab('get path'); // $ExpectType string
$(selector).tab('is tab'); // $ExpectType boolean
$(selector).tab('cache read', 'path'); // $ExpectType string | false
$(selector).tab('cache add', 'path', 'html'); // $ExpectType JQuery<HTMLElement>
$(selector).tab('cache remove', 'path'); // $ExpectType JQuery<HTMLElement>
$(selector).tab('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).tab('setting', 'debug', undefined); // $ExpectType boolean
$(selector).tab('setting', 'debug'); // $ExpectType boolean
$(selector).tab('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).tab('setting', {
namespace: 'namespace',
name: 'name',
@@ -28,7 +29,8 @@ function test_tab() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).tab({
auto: false,
deactivate: 'siblings',
@@ -56,56 +58,58 @@ function test_tab() {
urlData: false,
response: false,
responseAsync(settings, callback) {
settings === ({} as SemanticUI.ApiSettings);
callback === ((response: any) => { });
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
mockResponse: false,
mockResponseAsync(settings, callback) {
settings === ({} as SemanticUI.ApiSettings);
callback === ((response: any) => { });
settings; // $ExpectType Param
callback; // $ExpectType (response: any) => void
},
method: 'post',
dataType: 'xml',
data: {},
beforeSend(settings) {
settings === ({} as SemanticUI.ApiSettings);
settings; // $ExpectType Param
},
beforeXHR(xhrObject) {
xhrObject === ({} as JQueryXHR);
xhrObject; // $ExpectType jqXHR<any>
},
onRequest(promise, xhr) {
promise === ({} as JQueryDeferred<any>);
xhr === ({} as JQueryXHR);
promise; // $ExpectType Deferred<any, any, any>
xhr; // $ExpectType jqXHR<any>
},
onResponse(response) {
response === ({} as any);
response; // $ExpectType any
},
successTest(response) {
return response === ({} as any);
response; // $ExpectType any
return false;
},
onSuccess(response, element, xhr) {
response === ({} as any);
element === $();
xhr === ({} as JQueryXHR);
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onComplete(response, element, xhr) {
response === ({} as any);
element === $();
xhr === ({} as JQueryXHR);
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onFailure(response, element) {
response === ({} as any);
element === $();
response; // $ExpectType any
element; // $ExpectType JQuery<HTMLElement>
},
onError(errorMessage, element, xhr) {
errorMessage === '';
element === $();
xhr === ({} as JQueryXHR);
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
onAbort(errorMessage, element, xhr) {
errorMessage === '';
element === $();
xhr === ({} as JQueryXHR);
errorMessage; // $ExpectType string
element; // $ExpectType JQuery<HTMLElement>
xhr; // $ExpectType jqXHR<any>
},
regExp: {
required: /{\$*[A-z0-9]+}/g,
@@ -146,28 +150,29 @@ function test_tab() {
maxDepth: 10,
loadOnce: false,
onFirstLoad(tabPath, parameterArray, historyEvent) {
this === $();
tabPath === 'tabPath';
parameterArray === [];
historyEvent === {};
this; // $ExpectType JQuery<HTMLElement>
tabPath; // $ExpectType string
parameterArray; // $ExpectType any[]
historyEvent; // $ExpectType any
},
onLoad(tabPath, parameterArray, historyEvent) {
this === $();
tabPath === 'tabPath';
parameterArray === [];
historyEvent === {};
this; // $ExpectType JQuery<HTMLElement>
tabPath; // $ExpectType string
parameterArray; // $ExpectType any[]
historyEvent; // $ExpectType any
},
onRequest(tabPath) {
this === $();
tabPath === 'tabPath';
this; // $ExpectType JQuery<HTMLElement>
tabPath; // $ExpectType string
},
onVisible(tabPath) {
this === $();
tabPath === 'tabPath';
this; // $ExpectType JQuery<HTMLElement>
tabPath; // $ExpectType string
},
templates: {
determineTitle(tabArray) {
tabArray === [];
tabArray; // $ExpectType any[]
return 'title';
}
},
@@ -193,12 +198,16 @@ function test_tab() {
recursion: 'recursion',
state: 'state'
}
}) === $();
$(selector).tab() === $();
});
$(selector).tab(); // $ExpectType JQuery<HTMLElement>
$(selector).tab('foo'); // $ExpectError
$(selector).tab({ foo: 'bar' }); // $ExpectError
}
import tab = require('semantic-ui-tab');
function test_module() {
tab; // $ExpectType Tab
$.fn.tab = tab;
}
+44 -7
View File
@@ -95,19 +95,41 @@ declare namespace SemanticUI {
*/
(behavior: 'is supported'): boolean;
(behavior: 'destroy'): JQuery;
<K extends keyof TransitionSettings>(behavior: 'setting', name: K, value?: undefined): TransitionSettings[K];
<K extends keyof TransitionSettings>(behavior: 'setting', name: K, value: TransitionSettings[K]): JQuery;
(behavior: 'setting', value: TransitionSettings | object): JQuery;
<K extends keyof TransitionSettings>(behavior: 'setting', name: K, value?: undefined): TransitionSettings._Impl[K];
<K extends keyof TransitionSettings>(behavior: 'setting', name: K, value: TransitionSettings._Impl[K]): JQuery;
(behavior: 'setting', value: TransitionSettings): JQuery;
(transition: string): JQuery;
(settings?: TransitionSettings | object): JQuery;
(settings?: TransitionSettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/modules/transition.html#/settings}
*/
interface TransitionSettings extends Pick<TransitionSettings._Impl, keyof TransitionSettings._Impl> { }
type TransitionSettings = TransitionSettings.Param;
namespace TransitionSettings {
type Param = (Pick<_Impl, 'animation'> |
Pick<_Impl, 'interval'> |
Pick<_Impl, 'reverse'> |
Pick<_Impl, 'displayType'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'useFailSafe'> |
Pick<_Impl, 'allowRepeats'> |
Pick<_Impl, 'queue'> |
Pick<_Impl, 'onShow'> |
Pick<_Impl, 'onHide'> |
Pick<_Impl, 'onStart'> |
Pick<_Impl, 'onComplete'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Transition Settings
@@ -233,9 +255,20 @@ declare namespace SemanticUI {
}
namespace Transition {
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = (Pick<_Impl, 'animating'> |
Pick<_Impl, 'disabled'> |
Pick<_Impl, 'hidden'> |
Pick<_Impl, 'inward'> |
Pick<_Impl, 'loading'> |
Pick<_Impl, 'looping'> |
Pick<_Impl, 'outward'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'visible'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 'animating'
@@ -276,9 +309,13 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = (Pick<_Impl, 'noAnimation'> |
Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
* @default 'There is no CSS animation matching the one you specified.'
@@ -1,5 +1,5 @@
function test_static() {
$.fn.transition.settings.error.method = 'method';
$.fn.transition.settings.error!.method = 'method';
$.fn.transition.settings.namespace = 'namespace';
$.fn.transition.settings.name = 'name';
$.fn.transition.settings.silent = false;
@@ -10,32 +10,33 @@ function test_static() {
function test_transition() {
const selector = '.ui.transition';
$(selector).transition('stop') === $();
$(selector).transition('stop all') === $();
$(selector).transition('clear queue') === $();
$(selector).transition('show') === $();
$(selector).transition('hide') === $();
$(selector).transition('toggle') === $();
$(selector).transition('force repaint') === $();
$(selector).transition('repaint') === $();
$(selector).transition('reset') === $();
$(selector).transition('looping') === $();
$(selector).transition('remove looping') === $();
$(selector).transition('disable') === $();
$(selector).transition('enable') === $();
$(selector).transition('set duration', 10) === $();
$(selector).transition('save conditions') === $();
$(selector).transition('restore conditions') === $();
$(selector).transition('get animation name') === 'animation name';
$(selector).transition('get animation event') === 'animation event';
$(selector).transition('is visible') === false;
$(selector).transition('is animating') === false;
$(selector).transition('is looping') === false;
$(selector).transition('is supported') === false;
$(selector).transition('destroy') === $();
$(selector).transition('setting', 'debug', undefined) === false;
$(selector).transition('setting', 'debug') === false;
$(selector).transition('setting', 'debug', true) === $();
$(selector).transition('stop'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('stop all'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('clear queue'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('show'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('hide'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('toggle'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('force repaint'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('repaint'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('reset'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('looping'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('remove looping'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('disable'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('enable'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('set duration', 10); // $ExpectType JQuery<HTMLElement>
$(selector).transition('save conditions'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('restore conditions'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('get animation name'); // $ExpectType string
$(selector).transition('get animation event'); // $ExpectType string
$(selector).transition('is visible'); // $ExpectType boolean
$(selector).transition('is animating'); // $ExpectType boolean
$(selector).transition('is looping'); // $ExpectType boolean
$(selector).transition('is supported'); // $ExpectType boolean
$(selector).transition('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).transition('setting', 'debug', undefined); // $ExpectType boolean
$(selector).transition('setting', 'debug'); // $ExpectType boolean
$(selector).transition('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).transition('setting', {
namespace: 'namespace',
name: 'name',
@@ -43,8 +44,9 @@ function test_transition() {
debug: true,
performance: true,
verbose: true
}) === $();
$(selector).transition('fade') === $();
});
$(selector).transition('fade'); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).transition({
animation: 'fade',
interval: 200,
@@ -55,16 +57,16 @@ function test_transition() {
allowRepeats: true,
queue: false,
onShow() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onHide() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onStart() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onComplete() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
className: {
animating: 'animating',
@@ -81,12 +83,15 @@ function test_transition() {
noAnimation: 'noAnimation',
method: 'method'
}
}) === $();
$(selector).transition() === $();
});
$(selector).transition(); // $ExpectType JQuery<HTMLElement>
$(selector).transition({ foo: 'bar' }); // $ExpectError
}
import transition = require('semantic-ui-transition');
function test_module() {
transition; // $ExpectType Transition
$.fn.transition = transition;
}
+53 -10
View File
@@ -39,19 +39,60 @@ declare namespace SemanticUI {
*/
(behavior: 'get screen size'): Visibility.ScreenSize;
(behavior: 'destroy'): JQuery;
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value?: undefined): VisibilitySettings[K];
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value: VisibilitySettings[K]): JQuery;
(behavior: 'setting', value: VisibilitySettings.Param): JQuery;
(settings?: VisibilitySettings.Param): JQuery;
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value?: undefined): VisibilitySettings._Impl[K];
<K extends keyof VisibilitySettings>(behavior: 'setting', name: K, value: VisibilitySettings._Impl[K]): JQuery;
(behavior: 'setting', value: VisibilitySettings): JQuery;
(settings?: VisibilitySettings): JQuery;
}
/**
* @see {@link http://semantic-ui.com/behaviors/visibility.html#/settings}
*/
interface VisibilitySettings extends Pick<VisibilitySettings._Impl, keyof VisibilitySettings._Impl> { }
type VisibilitySettings = VisibilitySettings.Param;
namespace VisibilitySettings {
type Param = VisibilitySettings | object;
type Param = (Pick<_Impl, 'once'> |
Pick<_Impl, 'continuous'> |
Pick<_Impl, 'type'> |
Pick<_Impl, 'initialCheck'> |
Pick<_Impl, 'context'> |
Pick<_Impl, 'refreshOnLoad'> |
Pick<_Impl, 'refreshOnResize'> |
Pick<_Impl, 'checkOnRefresh'> |
Pick<_Impl, 'zIndex'> |
Pick<_Impl, 'offset'> |
Pick<_Impl, 'includeMargin'> |
Pick<_Impl, 'throttle'> |
Pick<_Impl, 'observeChanges'> |
Pick<_Impl, 'transition'> |
Pick<_Impl, 'duration'> |
Pick<_Impl, 'onTopVisible'> |
Pick<_Impl, 'onTopPassed'> |
Pick<_Impl, 'onBottomVisible'> |
Pick<_Impl, 'onPassing'> |
Pick<_Impl, 'onBottomPassed'> |
Pick<_Impl, 'onTopVisibleReverse'> |
Pick<_Impl, 'onTopPassedReverse'> |
Pick<_Impl, 'onBottomVisibleReverse'> |
Pick<_Impl, 'onPassingReverse'> |
Pick<_Impl, 'onBottomPassedReverse'> |
Pick<_Impl, 'onOnScreen'> |
Pick<_Impl, 'onOffScreen'> |
Pick<_Impl, 'onLoad'> |
Pick<_Impl, 'onAllLoaded'> |
Pick<_Impl, 'onFixed'> |
Pick<_Impl, 'onUnfixed'> |
Pick<_Impl, 'onUpdate'> |
Pick<_Impl, 'onRefresh'> |
Pick<_Impl, 'className'> |
Pick<_Impl, 'error'> |
Pick<_Impl, 'namespace'> |
Pick<_Impl, 'name'> |
Pick<_Impl, 'silent'> |
Pick<_Impl, 'debug'> |
Pick<_Impl, 'performance'> |
Pick<_Impl, 'verbose'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
// region Functionality
@@ -337,10 +378,11 @@ declare namespace SemanticUI {
height: number;
}
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
type ClassNameSettings = ClassNameSettings.Param;
namespace ClassNameSettings {
type Param = ClassNameSettings | object;
type Param = (Pick<_Impl, 'fixed'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -350,10 +392,11 @@ declare namespace SemanticUI {
}
}
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
type ErrorSettings = ErrorSettings.Param;
namespace ErrorSettings {
type Param = ErrorSettings | object;
type Param = (Pick<_Impl, 'method'>) &
Partial<Pick<_Impl, keyof _Impl>>;
interface _Impl {
/**
@@ -1,5 +1,5 @@
function test_visibility_static() {
$.fn.visibility.settings.error.method = 'method';
$.fn.visibility.settings.error!.method = 'method';
$.fn.visibility.settings.namespace = 'namespace';
$.fn.visibility.settings.name = 'name';
$.fn.visibility.settings.silent = false;
@@ -10,42 +10,19 @@ function test_visibility_static() {
function test_visibility() {
const selector = '.ui.visibility';
$(selector).visibility('disable callbacks') === $();
$(selector).visibility('enable callbacks') === $();
$(selector).visibility('is on screen') === false;
$(selector).visibility('is off screen') === true;
$(selector).visibility('get pixels passed') === 20;
$(selector).visibility('get element calculations') === {
fits: false,
offset: {
top: 955.96875,
left: 292
},
width: 466,
height: 1665.890625,
top: 955.96875,
bottom: 2621.859375,
topPassed: true,
bottomPassed: false,
topVisible: true,
bottomVisible: false,
pixelsPassed: 742.03125,
percentagePassed: 0.44542615155182,
onScreen: true,
passing: true,
offScreen: false
};
$(selector).visibility('get screen calculations') === {
bottom: 2658,
top: 1698
};
$(selector).visibility('get screen size') === {
height: 960
};
$(selector).visibility('destroy') === $();
$(selector).visibility('setting', 'debug', undefined) === false;
$(selector).visibility('setting', 'debug') === false;
$(selector).visibility('setting', 'debug', true) === $();
$(selector).visibility('disable callbacks'); // $ExpectType JQuery<HTMLElement>
$(selector).visibility('enable callbacks'); // $ExpectType JQuery<HTMLElement>
$(selector).visibility('is on screen'); // $ExpectType boolean
$(selector).visibility('is off screen'); // $ExpectType boolean
$(selector).visibility('get pixels passed'); // $ExpectType number
$(selector).visibility('get element calculations'); // $ExpectType ElementCalculations
$(selector).visibility('get screen calculations'); // $ExpectType ScreenCalculations
$(selector).visibility('get screen size'); // $ExpectType ScreenSize
$(selector).visibility('destroy'); // $ExpectType JQuery<HTMLElement>
$(selector).visibility('setting', 'debug', undefined); // $ExpectType boolean
$(selector).visibility('setting', 'debug'); // $ExpectType boolean
$(selector).visibility('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
// $ExpectType JQuery<HTMLElement>
$(selector).visibility('setting', {
namespace: 'namespace',
name: 'name',
@@ -53,7 +30,8 @@ function test_visibility() {
debug: true,
performance: true,
verbose: true
}) === $();
});
// $ExpectType JQuery<HTMLElement>
$(selector).visibility({
once: false,
continuous: true,
@@ -71,78 +49,59 @@ function test_visibility() {
transition: 'fade',
duration: 5,
onTopVisible() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onTopPassed() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onBottomVisible() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onPassing() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onBottomPassed() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onTopVisibleReverse() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onTopPassedReverse() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onBottomVisibleReverse() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onPassingReverse() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onBottomPassedReverse() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onOnScreen() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onOffScreen() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onLoad() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onAllLoaded() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onFixed() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onUnfixed() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
onUpdate(calculations) {
this === $();
calculations === {
fits: false,
offset: {
top: 955.96875,
left: 292
},
width: 466,
height: 1665.890625,
top: 955.96875,
bottom: 2621.859375,
topPassed: true,
bottomPassed: false,
topVisible: true,
bottomVisible: false,
pixelsPassed: 742.03125,
percentagePassed: 0.44542615155182,
onScreen: true,
passing: true,
offScreen: false
};
this; // $ExpectType JQuery<HTMLElement>
calculations; // $ExpectType ElementCalculations
},
onRefresh() {
this === $();
this; // $ExpectType JQuery<HTMLElement>
},
className: {
fixed: 'fixed',
@@ -150,12 +109,16 @@ function test_visibility() {
error: {
method: 'method'
}
}) === $();
$(selector).visibility() === $();
});
$(selector).visibility(); // $ExpectType JQuery<HTMLElement>
$(selector).visibility('foo'); // $ExpectError
$(selector).visibility({ foo: 'bar' }); // $ExpectError
}
import visibility = require('semantic-ui-visibility');
function test_module() {
visibility; // $ExpectType Visibility
$.fn.visibility = visibility;
}
+42 -62
View File
@@ -65,11 +65,11 @@ export function permutePath(path: string): string[];
// region Cookie
export class Cookie {
static parse(cookieString: string, options?: Cookie.ParseOptions | object): Cookie | undefined;
static parse(cookieString: string, options?: Cookie.ParseOptions): Cookie | undefined;
static fromJSON(strOrObj: string | object): Cookie | null;
constructor(properties?: Cookie.Properties | object);
constructor(properties?: Cookie.Properties);
// TODO: Some of the following properties might actually be nullable.
@@ -115,34 +115,26 @@ export class Cookie {
}
export namespace Cookie {
interface ParseOptions extends Pick<ParseOptions._Impl, keyof ParseOptions._Impl> { }
namespace ParseOptions {
interface _Impl {
loose: boolean;
}
interface ParseOptions {
loose?: boolean;
}
interface Properties extends Pick<Properties._Impl, keyof Properties._Impl> { }
interface Properties {
key?: string;
value?: string;
expires?: Date;
maxAge?: number | 'Infinity' | '-Infinity';
domain?: string;
path?: string;
secure?: boolean;
httpOnly?: boolean;
extensions?: string[];
creation?: Date;
creationIndex?: number;
namespace Properties {
interface _Impl {
key: string;
value: string;
expires: Date;
maxAge: number | 'Infinity' | '-Infinity';
domain: string;
path: string;
secure: boolean;
httpOnly: boolean;
extensions: string[];
creation: Date;
creationIndex: number;
hostOnly: boolean;
pathIsDefault: boolean;
lastAccessed: Date;
}
hostOnly?: boolean;
pathIsDefault?: boolean;
lastAccessed?: Date;
}
interface Serialized {
@@ -162,27 +154,27 @@ export class CookieJar {
static fromJSON(string: string): CookieJar;
constructor(store?: Store, options?: CookieJar.Options | object);
constructor(store?: Store, options?: CookieJar.Options);
setCookie(cookieOrString: Cookie | string, currentUrl: string, options: CookieJar.SetCookieOptions | object, cb: (err: Error | null, cookie: Cookie) => void): void;
setCookie(cookieOrString: Cookie | string, currentUrl: string, options: CookieJar.SetCookieOptions, cb: (err: Error | null, cookie: Cookie) => void): void;
setCookie(cookieOrString: Cookie | string, currentUrl: string, cb: (err: Error, cookie: Cookie) => void): void;
setCookieSync(cookieOrString: Cookie | string, currentUrl: string, options: CookieJar.SetCookieOptions | object): void;
setCookieSync(cookieOrString: Cookie | string, currentUrl: string, options: CookieJar.SetCookieOptions): void;
getCookies(currentUrl: string, options: CookieJar.GetCookiesOptions | object, cb: (err: Error | null, cookies: Cookie[]) => void): void;
getCookies(currentUrl: string, options: CookieJar.GetCookiesOptions, cb: (err: Error | null, cookies: Cookie[]) => void): void;
getCookies(currentUrl: string, cb: (err: Error | null, cookies: Cookie[]) => void): void;
getCookiesSync(currentUrl: string, options?: CookieJar.GetCookiesOptions | object): Cookie[];
getCookiesSync(currentUrl: string, options?: CookieJar.GetCookiesOptions): Cookie[];
getCookieString(currentUrl: string, options: CookieJar.GetCookiesOptions | object, cb: (err: Error | null, cookies: string) => void): void;
getCookieString(currentUrl: string, options: CookieJar.GetCookiesOptions, cb: (err: Error | null, cookies: string) => void): void;
getCookieString(currentUrl: string, cb: (err: Error | null, cookies: string) => void): void;
getCookieStringSync(currentUrl: string, options?: CookieJar.GetCookiesOptions | object): string;
getCookieStringSync(currentUrl: string, options?: CookieJar.GetCookiesOptions): string;
getSetCookieStrings(currentUrl: string, options: CookieJar.GetCookiesOptions | object, cb: (err: Error | null, cookies: string) => void): void;
getSetCookieStrings(currentUrl: string, options: CookieJar.GetCookiesOptions, cb: (err: Error | null, cookies: string) => void): void;
getSetCookieStrings(currentUrl: string, cb: (err: Error | null, cookies: string) => void): void;
getSetCookieStringsSync(currentUrl: string, options?: CookieJar.GetCookiesOptions | object): string;
getSetCookieStringsSync(currentUrl: string, options?: CookieJar.GetCookiesOptions): string;
serialize(cb: (err: Error | null, serializedObject: CookieJar.Serialized) => void): void;
@@ -197,36 +189,24 @@ export class CookieJar {
}
export namespace CookieJar {
interface Options extends Pick<Options._Impl, keyof Options._Impl> { }
namespace Options {
interface _Impl {
rejectPublicSuffixes: boolean;
looseMode: boolean;
}
interface Options {
rejectPublicSuffixes?: boolean;
looseMode?: boolean;
}
interface SetCookieOptions extends Pick<SetCookieOptions._Impl, keyof SetCookieOptions._Impl> { }
namespace SetCookieOptions {
interface _Impl {
http: boolean;
secure: boolean;
now: Date;
ignoreError: boolean;
}
interface SetCookieOptions {
http?: boolean;
secure?: boolean;
now?: Date;
ignoreError?: boolean;
}
interface GetCookiesOptions extends Pick<GetCookiesOptions._Impl, keyof GetCookiesOptions._Impl> { }
namespace GetCookiesOptions {
interface _Impl {
http: boolean;
secure: boolean;
date: Date;
expire: boolean;
allPoints: boolean;
}
interface GetCookiesOptions {
http?: boolean;
secure?: boolean;
date?: Date;
expire?: boolean;
allPoints?: boolean;
}
interface Serialized {