diff --git a/types/electron-settings/v2/index.d.ts b/types/electron-settings/v2/index.d.ts index 71677cb0df..a869fd52b8 100644 --- a/types/electron-settings/v2/index.d.ts +++ b/types/electron-settings/v2/index.d.ts @@ -2,7 +2,6 @@ // Project: https://github.com/nathanbuchar/electron-settings // Definitions by: Leonard Thieu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped -// TypeScript Version: 2.2 /// @@ -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; + set(keyPath: string, value: any, options?: ElectronSettings.Options): Promise; /** * 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; + delete(keyPath: string, options?: ElectronSettings.Options): Promise; /** * 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; + clear(options?: ElectronSettings.Options): Promise; /** * 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; + applyDefaults(options?: ElectronSettings.ApplyDefaultsOptions): Promise; /** * 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; + resetToDefaults(options?: ElectronSettings.Options): Promise; /** * 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 { } - - 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 { } - - 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 { diff --git a/types/electron-settings/v2/tsconfig.json b/types/electron-settings/v2/tsconfig.json index 3a5b7b152c..335711f7ef 100644 --- a/types/electron-settings/v2/tsconfig.json +++ b/types/electron-settings/v2/tsconfig.json @@ -4,6 +4,7 @@ "lib": [ "es6" ], + "target": "es2015", "noImplicitAny": true, "noImplicitThis": true, "strictNullChecks": true, diff --git a/types/semantic-ui-accordion/global.d.ts b/types/semantic-ui-accordion/global.d.ts index 33e3080dfb..5578714096 100644 --- a/types/semantic-ui-accordion/global.d.ts +++ b/types/semantic-ui-accordion/global.d.ts @@ -27,19 +27,41 @@ declare namespace SemanticUI { */ (behavior: 'toggle', index: number): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): AccordionSettings[K]; - (behavior: 'setting', name: K, value: AccordionSettings[K]): JQuery; - (behavior: 'setting', value: AccordionSettings.Param): JQuery; - (settings?: AccordionSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): AccordionSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Behavior @@ -181,10 +203,14 @@ declare namespace SemanticUI { } namespace Accordion { - interface SelectorSettings extends Pick { } + 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>; interface _Impl { /** @@ -206,10 +232,12 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { - type Param = ClassNameSettings | object; + type Param = (Pick<_Impl, 'active'> | + Pick<_Impl, 'animating'>) & + Partial>; interface _Impl { /** @@ -223,10 +251,11 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-accordion/semantic-ui-accordion-tests.ts b/types/semantic-ui-accordion/semantic-ui-accordion-tests.ts index 7ab192f847..87aad211e1 100644 --- a/types/semantic-ui-accordion/semantic-ui-accordion-tests.ts +++ b/types/semantic-ui-accordion/semantic-ui-accordion-tests.ts @@ -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 + $(selector).accordion('open', 3); // $ExpectType JQuery + $(selector).accordion('close others'); // $ExpectType JQuery + $(selector).accordion('close', 10); // $ExpectType JQuery + $(selector).accordion('toggle', 5); // $ExpectType JQuery + $(selector).accordion('destroy'); // $ExpectType JQuery + $(selector).accordion('setting', 'debug', undefined); // $ExpectType boolean + $(selector).accordion('setting', 'debug'); // $ExpectType boolean + $(selector).accordion('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).accordion('setting', { namespace: 'namespace', name: 'name', @@ -25,7 +26,8 @@ function test_accordion() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).accordion({ exclusive: true, on: 'on', @@ -36,19 +38,19 @@ function test_accordion() { easing: 'easeInOutQuint', observeChanges: true, onOpening() { - this === $(); + this; // $ExpectType JQuery }, onOpen() { - this === $(); + this; // $ExpectType JQuery }, onClosing() { - this === $(); + this; // $ExpectType JQuery }, onClose() { - this === $(); + this; // $ExpectType JQuery }, onChange() { - this === $(); + this; // $ExpectType JQuery }, selector: { accordion: 'accordion', @@ -63,12 +65,16 @@ function test_accordion() { error: { method: 'method' } - }) === $(); - $(selector).accordion() === $(); + }); + $(selector).accordion(); // $ExpectType JQuery + + $(selector).accordion('foo'); // $ExpectError + $(selector).accordion({ foo: 'bar' }); // $ExpectError } import accordion = require('semantic-ui-accordion'); function test_module() { + accordion; // $ExpectType Accordion $.fn.accordion = accordion; } diff --git a/types/semantic-ui-api/global.d.ts b/types/semantic-ui-api/global.d.ts index 5c644a4d8d..a9799bad44 100644 --- a/types/semantic-ui-api/global.d.ts +++ b/types/semantic-ui-api/global.d.ts @@ -98,18 +98,63 @@ declare namespace SemanticUI { * Removes API settings from the page and all events */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): ApiSettings[K]; - (behavior: 'setting', name: K, value: ApiSettings[K]): JQuery; - (behavior: 'setting', value: ApiSettings | object): JQuery; - (settings?: ApiSettings | object): JQuery; + (behavior: 'setting', name: K, value?: undefined): ApiSettings._Impl[K]; + (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 { } + 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>; + 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, xhr: JQueryXHR): void; + onRequest(promise: JQuery.Deferred, 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 { } + type RegExpSettings = RegExpSettings.Param; namespace RegExpSettings { + type Param = (Pick<_Impl, 'required'> | + Pick<_Impl, 'optional'>) & + Partial>; + interface _Impl { /** * @default /\{\$*[A-z0-9]+\}/g @@ -367,9 +416,13 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { + type Param = (Pick<_Impl, 'disabled'> | + Pick<_Impl, 'form'>) & + Partial>; + interface _Impl { /** * @default '.disabled' @@ -382,9 +435,13 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { + type Param = (Pick<_Impl, 'loading'> | + Pick<_Impl, 'error'>) & + Partial>; + interface _Impl { /** * @default 'loading' @@ -397,9 +454,13 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + type MetadataSettings = MetadataSettings.Param; namespace MetadataSettings { + type Param = (Pick<_Impl, 'action'> | + Pick<_Impl, 'url'>) & + Partial>; + interface _Impl { /** * @default 'action' @@ -412,9 +473,24 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + 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>; + interface _Impl { /** * @default 'The before send function has aborted the request' diff --git a/types/semantic-ui-api/semantic-ui-api-tests.ts b/types/semantic-ui-api/semantic-ui-api-tests.ts index 683c1a35c4..ca8107d8ec 100644 --- a/types/semantic-ui-api/semantic-ui-api-tests.ts +++ b/types/semantic-ui-api/semantic-ui-api-tests.ts @@ -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 + $(selector).api('setting', 'debug', undefined); // $ExpectType boolean + $(selector).api('setting', 'debug'); // $ExpectType boolean + $(selector).api('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).api('setting', { namespace: 'namespace', name: 'name', @@ -28,7 +29,8 @@ function test_api() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 }, onRequest(promise, xhr) { - promise === ({} as JQueryDeferred); - xhr === ({} as JQueryXHR); + promise; // $ExpectType Deferred + xhr; // $ExpectType jqXHR }, 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 + xhr; // $ExpectType jqXHR }, onComplete(response, element, xhr) { - response === ({} as any); - element === $(); - xhr === ({} as JQueryXHR); + response; // $ExpectType any + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, onFailure(response, element) { - response === ({} as any); - element === $(); + response; // $ExpectType any + element; // $ExpectType JQuery }, onError(errorMessage, element, xhr) { - errorMessage === ''; - element === $(); - xhr === ({} as JQueryXHR); + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, onAbort(errorMessage, element, xhr) { - errorMessage === ''; - element === $(); - xhr === ({} as JQueryXHR); + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, regExp: { required: /{\$*[A-z0-9]+}/g, @@ -129,12 +133,16 @@ function test_api() { statusMessage: 'statusMessage', timeout: 'timeout' } - }) === $(); - $(selector).api() === $(); + }); + $(selector).api(); // $ExpectType JQuery + + $(selector).api('foo'); // $ExpectError + $(selector).api({ foo: 'bar' }); // $ExpectError } import api = require('semantic-ui-api'); function test_module() { + api; // $ExpectType Api $.fn.api = api; } diff --git a/types/semantic-ui-checkbox/global.d.ts b/types/semantic-ui-checkbox/global.d.ts index fd3159b5b6..5493498b41 100644 --- a/types/semantic-ui-checkbox/global.d.ts +++ b/types/semantic-ui-checkbox/global.d.ts @@ -95,19 +95,43 @@ declare namespace SemanticUI { */ (behavior: 'can uncheck'): boolean; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): CheckboxSettings[K]; - (behavior: 'setting', name: K, value: CheckboxSettings[K]): JQuery; - (behavior: 'setting', value: CheckboxSettings.Param): JQuery; - (settings?: CheckboxSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): CheckboxSettings._Impl[K]; + (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 { } + 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>; 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 { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'input'> | + Pick<_Impl, 'label'>) & + Partial>; interface _Impl { /** @@ -265,10 +291,14 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -290,10 +320,11 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-checkbox/semantic-ui-checkbox-tests.ts b/types/semantic-ui-checkbox/semantic-ui-checkbox-tests.ts index 30ff41ebd3..3e0e574eb1 100644 --- a/types/semantic-ui-checkbox/semantic-ui-checkbox-tests.ts +++ b/types/semantic-ui-checkbox/semantic-ui-checkbox-tests.ts @@ -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 + $(selector).checkbox('check'); // $ExpectType JQuery + $(selector).checkbox('uncheck'); // $ExpectType JQuery + $(selector).checkbox('indeterminate'); // $ExpectType JQuery + $(selector).checkbox('determinate'); // $ExpectType JQuery + $(selector).checkbox('enable'); // $ExpectType JQuery + $(selector).checkbox('set checked'); // $ExpectType JQuery + $(selector).checkbox('set unchecked'); // $ExpectType JQuery + $(selector).checkbox('set indeterminate'); // $ExpectType JQuery + $(selector).checkbox('set determinate'); // $ExpectType JQuery + $(selector).checkbox('set enabled'); // $ExpectType JQuery + $(selector).checkbox('set disabled'); // $ExpectType JQuery + $(selector).checkbox('attach events', $(), 'click'); // $ExpectType JQuery + $(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 + // $ExpectType JQuery $(selector).checkbox('setting', { namespace: 'namespace', name: 'name', @@ -42,48 +43,57 @@ function test_checkbox() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 + + $(selector).checkbox('foo'); // $ExpectError + $(selector).checkbox({ foo: 'bar' }); // $ExpectError } import checkbox = require('semantic-ui-checkbox'); function test_module() { + checkbox; // $ExpectType Checkbox $.fn.checkbox = checkbox; } diff --git a/types/semantic-ui-dimmer/global.d.ts b/types/semantic-ui-dimmer/global.d.ts index 86ac3dc056..4b06951be9 100644 --- a/types/semantic-ui-dimmer/global.d.ts +++ b/types/semantic-ui-dimmer/global.d.ts @@ -95,18 +95,41 @@ declare namespace SemanticUI { */ (behavior: 'set disabled'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): DimmerSettings[K]; - (behavior: 'setting', name: K, value: DimmerSettings[K]): JQuery; - (behavior: 'setting', value: DimmerSettings | object): JQuery; - (settings?: DimmerSettings | object): JQuery; + (behavior: 'setting', name: K, value?: undefined): DimmerSettings._Impl[K]; + (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 { } + 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>; + interface _Impl { // region Behavior @@ -244,9 +267,13 @@ declare namespace SemanticUI { } namespace Dimmer { - interface DurationSettings extends Pick { } + type DurationSettings = DurationSettings.Param; namespace DurationSettings { + type Param = (Pick<_Impl, 'show'> | + Pick<_Impl, 'hide'>) & + Partial>; + interface _Impl { /** * @default 500 @@ -259,9 +286,14 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { + type Param = (Pick<_Impl, 'dimmable'> | + Pick<_Impl, 'dimmer'> | + Pick<_Impl, 'content'>) & + Partial>; + interface _Impl { /** * @default '.dimmable' @@ -278,17 +310,30 @@ declare namespace SemanticUI { } } - interface TemplateSettings extends Pick { } + type TemplateSettings = TemplateSettings.Param; namespace TemplateSettings { + type Param = (Pick<_Impl, 'dimmer'>) & + Partial>; + interface _Impl { dimmer(): JQuery; } } - interface ClassNameSettings extends Pick { } + 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>; + interface _Impl { /** * @default 'active' @@ -325,9 +370,12 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { + type Param = (Pick<_Impl, 'method'>) & + Partial>; + interface _Impl { /** * @default 'The method you called is not defined.' diff --git a/types/semantic-ui-dimmer/semantic-ui-dimmer-tests.ts b/types/semantic-ui-dimmer/semantic-ui-dimmer-tests.ts index 68aa418a7d..ef6701f8c1 100644 --- a/types/semantic-ui-dimmer/semantic-ui-dimmer-tests.ts +++ b/types/semantic-ui-dimmer/semantic-ui-dimmer-tests.ts @@ -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 + $(selector).dimmer('show'); // $ExpectType JQuery + $(selector).dimmer('hide'); // $ExpectType JQuery + $(selector).dimmer('toggle'); // $ExpectType JQuery + $(selector).dimmer('set opacity', 1); // $ExpectType JQuery + $(selector).dimmer('create'); // $ExpectType JQuery + $(selector).dimmer('get duration'); // $ExpectType number + $(selector).dimmer('get dimmer'); // $ExpectType JQuery + $(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 + $(selector).dimmer('set dimmable'); // $ExpectType JQuery + $(selector).dimmer('set dimmed'); // $ExpectType JQuery + $(selector).dimmer('set page dimmer'); // $ExpectType JQuery + $(selector).dimmer('set disabled'); // $ExpectType JQuery + $(selector).dimmer('destroy'); // $ExpectType JQuery + $(selector).dimmer('setting', 'debug', undefined); // $ExpectType boolean + $(selector).dimmer('setting', 'debug'); // $ExpectType boolean + $(selector).dimmer('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).dimmer('setting', { namespace: 'namespace', name: 'name', @@ -43,7 +44,8 @@ function test_dimmer() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).dimmer({ opacity: 1, variation: 'variation', @@ -57,13 +59,13 @@ function test_dimmer() { }, transition: 'fade', onShow() { - this === $(); + this; // $ExpectType JQuery }, onHide() { - this === $(); + this; // $ExpectType JQuery }, onChange() { - this === $(); + this; // $ExpectType JQuery }, selector: { dimmable: '.dimmable', @@ -88,12 +90,16 @@ function test_dimmer() { error: { method: 'method' } - }) === $(); - $(selector).dimmer() === $(); + }); + $(selector).dimmer(); // $ExpectType JQuery + + $(selector).dimmer('foo'); // $ExpectError + $(selector).dimmer({ foo: 'bar' }); // $ExpectError } import dimmer = require('semantic-ui-dimmer'); function test_module() { + dimmer; // $ExpectType Dimmer $.fn.dimmer = dimmer; } diff --git a/types/semantic-ui-dropdown/global.d.ts b/types/semantic-ui-dropdown/global.d.ts index 12425cbace..8fc8c234cd 100644 --- a/types/semantic-ui-dropdown/global.d.ts +++ b/types/semantic-ui-dropdown/global.d.ts @@ -157,19 +157,71 @@ declare namespace SemanticUI { */ (behavior: 'get placeholder text'): string; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): DropdownSettings[K]; - (behavior: 'setting', name: K, value: DropdownSettings[K]): JQuery; - (behavior: 'setting', value: DropdownSettings.Param): JQuery; - (settings?: DropdownSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): DropdownSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Frequently Used Settings @@ -475,10 +527,14 @@ declare namespace SemanticUI { } namespace Dropdown { - interface FieldsSettings extends Pick { } + 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>; interface _Impl { /** @@ -508,10 +564,13 @@ declare namespace SemanticUI { } } - interface LabelSettings extends Pick { } + type LabelSettings = LabelSettings.Param; namespace LabelSettings { - type Param = LabelSettings | object; + type Param = (Pick<_Impl, 'transition'> | + Pick<_Impl, 'duration'> | + Pick<_Impl, 'variation'>) & + Partial>; interface _Impl { /** @@ -529,10 +588,21 @@ declare namespace SemanticUI { } } - interface KeySettings extends Pick { } + 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>; interface _Impl { /** @@ -582,10 +652,14 @@ declare namespace SemanticUI { } } - interface DelaySettings extends Pick { } + 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>; interface _Impl { /** @@ -607,10 +681,14 @@ declare namespace SemanticUI { } } - interface MessageSettings extends Pick { } + 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>; interface _Impl { /** @@ -632,10 +710,23 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + 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>; interface _Impl { /** @@ -693,10 +784,11 @@ declare namespace SemanticUI { } } - interface RegExpSettings extends Pick { } + type RegExpSettings = RegExpSettings.Param; namespace RegExpSettings { - type Param = RegExpSettings | object; + type Param = (Pick<_Impl, 'escape'>) & + Partial>; interface _Impl { /** @@ -706,10 +798,15 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + 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>; interface _Impl { /** @@ -735,10 +832,29 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -820,10 +936,15 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + 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>; interface _Impl { /** diff --git a/types/semantic-ui-dropdown/semantic-ui-dropdown-tests.ts b/types/semantic-ui-dropdown/semantic-ui-dropdown-tests.ts index 2dafbf9c8e..915f96e40f 100644 --- a/types/semantic-ui-dropdown/semantic-ui-dropdown-tests.ts +++ b/types/semantic-ui-dropdown/semantic-ui-dropdown-tests.ts @@ -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 + $(selector).dropdown('refresh'); // $ExpectType JQuery + $(selector).dropdown('toggle'); // $ExpectType JQuery + $(selector).dropdown('show'); // $ExpectType JQuery + $(selector).dropdown('hide'); // $ExpectType JQuery + $(selector).dropdown('clear'); // $ExpectType JQuery + $(selector).dropdown('hide others'); // $ExpectType JQuery + $(selector).dropdown('restore defaults'); // $ExpectType JQuery + $(selector).dropdown('restore default text'); // $ExpectType JQuery + $(selector).dropdown('restore placeholder text'); // $ExpectType JQuery + $(selector).dropdown('restore default value'); // $ExpectType JQuery + $(selector).dropdown('save defaults'); // $ExpectType JQuery + $(selector).dropdown('set selected', 123); // $ExpectType JQuery + $(selector).dropdown('remove selected', false); // $ExpectType JQuery + $(selector).dropdown('set selected', ['456']); // $ExpectType JQuery + $(selector).dropdown('set exactly', []); // $ExpectType JQuery + $(selector).dropdown('set text', 'hello'); // $ExpectType JQuery + $(selector).dropdown('set value', 24); // $ExpectType JQuery + $(selector).dropdown('get text'); // $ExpectType string + $(selector).dropdown('get value'); // $ExpectType any + $(selector).dropdown('get item', 'Pennsylvania'); // $ExpectType JQuery + $(selector).dropdown('bind touch events'); // $ExpectType JQuery + $(selector).dropdown('bind mouse events'); // $ExpectType JQuery + $(selector).dropdown('bind intent'); // $ExpectType JQuery + $(selector).dropdown('unbind intent'); // $ExpectType JQuery + $(selector).dropdown('determine intent'); // $ExpectType boolean + $(selector).dropdown('determine select action', 'text', 90); // $ExpectType JQuery + $(selector).dropdown('set active'); // $ExpectType JQuery + $(selector).dropdown('set visible'); // $ExpectType JQuery + $(selector).dropdown('remove active'); // $ExpectType JQuery + $(selector).dropdown('remove visible'); // $ExpectType JQuery + $(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 + $(selector).dropdown('setting', 'debug', undefined); // $ExpectType boolean + $(selector).dropdown('setting', 'debug'); // $ExpectType boolean + $(selector).dropdown('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).dropdown('setting', { namespace: 'namespace', name: 'name', @@ -58,19 +59,18 @@ function test_dropdown() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 + text; // $ExpectType string + value; // $ExpectType string | false + element; // $ExpectType JQuery }, 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 + }, + onRequest(promise, xhr) { + promise; // $ExpectType Deferred + xhr; // $ExpectType jqXHR + }, + onResponse(response) { + response; // $ExpectType any + }, + successTest(response) { + response; // $ExpectType any + + return false; + }, + onSuccess(response, element, xhr) { + response; // $ExpectType any + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR + }, + onComplete(response, element, xhr) { + response; // $ExpectType any + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR + }, + onFailure(response, element) { + response; // $ExpectType any + element; // $ExpectType JQuery + }, + onError(errorMessage, element, xhr) { + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR + }, + onAbort(errorMessage, element, xhr) { + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR + }, + 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 }, onAdd(addedValue, addedText, $addedChoice) { - addedValue === {}; - addedText === 'addedText'; - $addedChoice === $(); + addedValue; // $ExpectType any + addedText; // $ExpectType string + $addedChoice; // $ExpectType JQuery }, message: { addResult: 'addResult', @@ -197,12 +295,16 @@ function test_dropdown() { method: 'method', noTransition: 'noTransition' } - }) === $(); - $(selector).dropdown() === $(); + }); + $(selector).dropdown(); // $ExpectType JQuery + + $(selector).dropdown('foo'); // $ExpectError + $(selector).dropdown({ foo: 'bar' }); // $ExpectError } import dropdown = require('semantic-ui-dropdown'); function test_module() { + dropdown; // $ExpectType Dropdown $.fn.dropdown = dropdown; } diff --git a/types/semantic-ui-embed/global.d.ts b/types/semantic-ui-embed/global.d.ts index e851b252a1..c9a096649c 100644 --- a/types/semantic-ui-embed/global.d.ts +++ b/types/semantic-ui-embed/global.d.ts @@ -50,19 +50,43 @@ declare namespace SemanticUI { * Destroys instance and removes all events */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): EmbedSettings[K]; - (behavior: 'setting', name: K, value: EmbedSettings[K]): JQuery; - (behavior: 'setting', value: EmbedSettings.Param): JQuery; - (settings?: EmbedSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): EmbedSettings._Impl[K]; + (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 { } + 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>; interface _Impl { /** @@ -216,20 +240,23 @@ declare namespace SemanticUI { } namespace Embed { - interface ParametersSettings extends Pick { } + type ParametersSettings = ParametersSettings._Impl; namespace ParametersSettings { - type Param = ParametersSettings | object; + type Param = _Impl; interface _Impl { [key: string]: any; } } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'embed'> | + Pick<_Impl, 'placeholder'> | + Pick<_Impl, 'play'>) & + Partial>; interface _Impl { /** @@ -247,10 +274,15 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + 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>; interface _Impl { /** @@ -276,10 +308,12 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { - type Param = ClassNameSettings | object; + type Param = (Pick<_Impl, 'active'> | + Pick<_Impl, 'embed'>) & + Partial>; interface _Impl { /** @@ -293,10 +327,12 @@ declare namespace SemanticUI { } } - interface TemplatesSettings extends Pick { } + type TemplatesSettings = TemplatesSettings.Param; namespace TemplatesSettings { - type Param = TemplatesSettings | object; + type Param = (Pick<_Impl, 'iframe'> | + Pick<_Impl, 'placeholder'>) & + Partial>; interface _Impl { /** @@ -310,10 +346,12 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'noURL'> | + Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-embed/semantic-ui-embed-tests.ts b/types/semantic-ui-embed/semantic-ui-embed-tests.ts index 486092a2a1..63d6769763 100644 --- a/types/semantic-ui-embed/semantic-ui-embed-tests.ts +++ b/types/semantic-ui-embed/semantic-ui-embed-tests.ts @@ -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 + $(selector).embed('reset'); // $ExpectType JQuery + $(selector).embed('show'); // $ExpectType JQuery + $(selector).embed('hide'); // $ExpectType JQuery + $(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 + $(selector).embed('setting', 'debug', undefined); // $ExpectType boolean + $(selector).embed('setting', 'debug'); // $ExpectType boolean + $(selector).embed('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).embed('setting', { namespace: 'namespace', name: 'name', @@ -31,7 +32,8 @@ function test_embed() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 + url; // $ExpectType string }, onDisplay() { - this === $(); + this; // $ExpectType JQuery }, onPlaceholderDisplay() { - this === $(); + this; // $ExpectType JQuery }, onEmbed(parameters) { - this === $(); - parameters.key = 'value'; + this; // $ExpectType JQuery + 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 '
'; }, placeholder(image, icon) { - image === 'image'; - icon === 'icon'; - return image + icon; + image; // $ExpectType string + icon; // $ExpectType string + + return '
'; } }, error: { noURL: 'noURL', method: 'method' } - }) === $(); - $(selector).embed() === $(); + }); + $(selector).embed(); // $ExpectType JQuery + + $(selector).embed('foo'); // $ExpectError + $(selector).embed({ foo: 'bar' }); // $ExpectError } import embed = require('semantic-ui-embed'); function test_module() { + embed; // $ExpectType Embed $.fn.embed = embed; } diff --git a/types/semantic-ui-form/global.d.ts b/types/semantic-ui-form/global.d.ts index 13fefb8147..3f8b3977e9 100644 --- a/types/semantic-ui-form/global.d.ts +++ b/types/semantic-ui-form/global.d.ts @@ -55,19 +55,45 @@ declare namespace SemanticUI { */ (behavior: 'add errors', errors: string[]): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): FormSettings[K]; - (behavior: 'setting', name: K, value: FormSettings[K]): JQuery; - (behavior: 'setting', value: FormSettings.Param): JQuery; - (settings?: FormSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): FormSettings._Impl[K]; + (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 { } + 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>; 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, fields: any): void; /** * Callback if any form field is invalid */ @@ -237,10 +263,12 @@ declare namespace SemanticUI { prompt: string; } - interface TextSettings extends Pick { } + type TextSettings = TextSettings.Param; namespace TextSettings { - type Param = TextSettings | object; + type Param = (Pick<_Impl, 'unspecifiedRule'> | + Pick<_Impl, 'unspecifiedField'>) & + Partial>; interface _Impl { /** @@ -254,10 +282,36 @@ declare namespace SemanticUI { } } - interface PromptSettings extends Pick { } + 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>; interface _Impl { /** @@ -367,10 +421,12 @@ declare namespace SemanticUI { } } - interface TemplatesSettings extends Pick { } + type TemplatesSettings = TemplatesSettings.Param; namespace TemplatesSettings { - type Param = TemplatesSettings | object; + type Param = (Pick<_Impl, 'error'> | + Pick<_Impl, 'prompt'>) & + Partial>; interface _Impl { error(errors: string[]): JQuery; @@ -378,10 +434,16 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + 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>; interface _Impl { /** @@ -411,10 +473,11 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + type MetadataSettings = MetadataSettings.Param; namespace MetadataSettings { - type Param = MetadataSettings | object; + type Param = (Pick<_Impl, 'validate'>) & + Partial>; interface _Impl { /** @@ -424,10 +487,14 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -449,10 +516,11 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-form/semantic-ui-form-tests.ts b/types/semantic-ui-form/semantic-ui-form-tests.ts index 58e8a18f70..56293fc5b4 100644 --- a/types/semantic-ui-form/semantic-ui-form-tests.ts +++ b/types/semantic-ui-form/semantic-ui-form-tests.ts @@ -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 + $(selector).form('is valid'); // $ExpectType boolean + $(selector).form('validate form'); // $ExpectType JQuery $(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 + $(selector).form('get value', 'id'); // $ExpectType any + $(selector).form('get values', ['id1', 'id2']); // $ExpectType any + $(selector).form('set value', 'id'); // $ExpectType JQuery + $(selector).form('set values', ['id1', 'id2']); // $ExpectType JQuery + $(selector).form('get validation', $()); // $ExpectType any + $(selector).form('has field', 'identifier'); // $ExpectType boolean + $(selector).form('add errors', ['error1', 'error2']); // $ExpectType JQuery + $(selector).form('destroy'); // $ExpectType JQuery + $(selector).form('setting', 'debug', undefined); // $ExpectType boolean + $(selector).form('setting', 'debug'); // $ExpectType boolean + $(selector).form('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).form('setting', { namespace: 'namespace', name: 'name', @@ -33,12 +34,13 @@ function test_form() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 }, onInvalid() { - this === $(); + this; // $ExpectType JQuery }, onSuccess(event, fields) { - this === $(); - event.stopPropagation(); - fields === {}; + this; // $ExpectType JQuery + event; // $ExpectType Event + fields; // $ExpectType any }, onFailure(formErrors, fields) { - this === $(); - formErrors === []; - fields === {}; + this; // $ExpectType JQuery + 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 + + $(selector).form('foo'); // $ExpectError + $(selector).form({ foo: 'bar' }); // $ExpectError } import form = require('semantic-ui-form'); function test_module() { + form; // $ExpectType Form $.fn.form = form; } diff --git a/types/semantic-ui-modal/global.d.ts b/types/semantic-ui-modal/global.d.ts index 84f9116e8b..2e6efc4e1d 100644 --- a/types/semantic-ui-modal/global.d.ts +++ b/types/semantic-ui-modal/global.d.ts @@ -56,19 +56,46 @@ declare namespace SemanticUI { (behavior: 'set active'): JQuery; (behavior: 'attach events', selector: string | JQuery, event?: string): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): ModalSettings[K]; - (behavior: 'setting', name: K, value: ModalSettings[K]): JQuery; - (behavior: 'setting', value: ModalSettings.Param): JQuery; - (settings?: ModalSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): ModalSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Modal Settings @@ -232,10 +259,13 @@ declare namespace SemanticUI { } namespace Modal { - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'close'> | + Pick<_Impl, 'approve'> | + Pick<_Impl, 'deny'>) & + Partial>; interface _Impl { /** @@ -253,10 +283,12 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { - type Param = ClassNameSettings | object; + type Param = (Pick<_Impl, 'active'> | + Pick<_Impl, 'scrolling'>) & + Partial>; interface _Impl { /** @@ -270,10 +302,11 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-modal/semantic-ui-modal-tests.ts b/types/semantic-ui-modal/semantic-ui-modal-tests.ts index ed2a10d3e2..422b5de2e6 100644 --- a/types/semantic-ui-modal/semantic-ui-modal-tests.ts +++ b/types/semantic-ui-modal/semantic-ui-modal-tests.ts @@ -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 + $(selector).modal('hide'); // $ExpectType JQuery + $(selector).modal('toggle'); // $ExpectType JQuery + $(selector).modal('refresh'); // $ExpectType JQuery + $(selector).modal('show dimmer'); // $ExpectType JQuery + $(selector).modal('hide dimmer'); // $ExpectType JQuery + $(selector).modal('hide others'); // $ExpectType JQuery + $(selector).modal('hide all'); // $ExpectType JQuery + $(selector).modal('cache sizes'); // $ExpectType JQuery + $(selector).modal('can fit'); // $ExpectType boolean + $(selector).modal('is active'); // $ExpectType boolean + $(selector).modal('set active'); // $ExpectType JQuery + $(selector).modal('attach events', 'selector', 'blur'); // $ExpectType JQuery + $(selector).modal('destroy'); // $ExpectType JQuery + $(selector).modal('setting', 'debug', undefined); // $ExpectType boolean + $(selector).modal('setting', 'debug'); // $ExpectType boolean + $(selector).modal('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).modal('setting', { namespace: 'namespace', name: 'name', @@ -34,7 +35,8 @@ function test_modal() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).modal({ detachable: true, autofocus: false, @@ -57,13 +59,13 @@ function test_modal() { }, transition: 'fade', onShow() { - this === $(); + this; // $ExpectType JQuery }, onHide() { - this === $(); + this; // $ExpectType JQuery }, onChange() { - this === $(); + this; // $ExpectType JQuery }, selector: { dimmable: '.dimmable', @@ -93,27 +95,30 @@ function test_modal() { duration: 400, queue: true, onShow() { - this === $(); + this; // $ExpectType JQuery }, onVisible() { - this === $(); + this; // $ExpectType JQuery }, onHide($element) { - this === $(); - $element === $(); + this; // $ExpectType JQuery + $element; // $ExpectType JQuery + return false; }, onHidden() { - this === $(); + this; // $ExpectType JQuery }, onApprove($element) { - this === $(); - $element === $(); + this; // $ExpectType JQuery + $element; // $ExpectType JQuery + return false; }, onDeny($element) { - this === $(); - $element === $(); + this; // $ExpectType JQuery + $element; // $ExpectType JQuery + return false; }, selector: { @@ -128,12 +133,16 @@ function test_modal() { error: { method: 'method' } - }) === $(); - $(selector).modal() === $(); + }); + $(selector).modal(); // $ExpectType JQuery + + $(selector).modal('foo'); // $ExpectError + $(selector).modal({ foo: 'bar' }); // $ExpectError } import modal = require('semantic-ui-modal'); function test_module() { + modal; // $ExpectType Modal $.fn.modal = modal; } diff --git a/types/semantic-ui-nag/global.d.ts b/types/semantic-ui-nag/global.d.ts index 6ac11501cb..5cb597e8da 100644 --- a/types/semantic-ui-nag/global.d.ts +++ b/types/semantic-ui-nag/global.d.ts @@ -13,19 +13,42 @@ declare namespace SemanticUI { */ (behavior: 'clear'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): NagSettings[K]; - (behavior: 'setting', name: K, value: NagSettings[K]): JQuery; - (behavior: 'setting', value: NagSettings.Param): JQuery; - (settings?: NagSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): NagSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Behavior @@ -152,10 +175,12 @@ declare namespace SemanticUI { } namespace Nag { - interface AnimationSettings extends Pick { } + type AnimationSettings = AnimationSettings.Param; namespace AnimationSettings { - type Param = AnimationSettings | object; + type Param = (Pick<_Impl, 'show'> | + Pick<_Impl, 'hide'>) & + Partial>; interface _Impl { /** @@ -169,10 +194,12 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { - type Param = ClassNameSettings | object; + type Param = (Pick<_Impl, 'bottom'> | + Pick<_Impl, 'fixed'>) & + Partial>; interface _Impl { /** @@ -186,10 +213,11 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'close'>) & + Partial>; interface _Impl { /** @@ -199,10 +227,13 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'noCookieStorage'> | + Pick<_Impl, 'noStorage'> | + Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-nag/semantic-ui-nag-tests.ts b/types/semantic-ui-nag/semantic-ui-nag-tests.ts index 45a95b827b..ba39bfad5d 100644 --- a/types/semantic-ui-nag/semantic-ui-nag-tests.ts +++ b/types/semantic-ui-nag/semantic-ui-nag-tests.ts @@ -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 + $(selector).nag('hide'); // $ExpectType JQuery + $(selector).nag('clear'); // $ExpectType JQuery + $(selector).nag('destroy'); // $ExpectType JQuery + $(selector).nag('setting', 'debug', undefined); // $ExpectType boolean + $(selector).nag('setting', 'debug'); // $ExpectType boolean + $(selector).nag('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).nag('setting', { namespace: 'namespace', name: 'name', @@ -24,7 +25,8 @@ function test_nag() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).nag({ persist: true, displayTime: 0, @@ -43,7 +45,7 @@ function test_nag() { speed: 500, easing: 'easeOutQuad', onHide() { - this === $(); + this; // $ExpectType JQuery }, className: { bottom: 'bottom', @@ -57,12 +59,16 @@ function test_nag() { noStorage: 'noStorage', method: 'method' } - }) === $(); - $(selector).nag() === $(); + }); + $(selector).nag(); // $ExpectType JQuery + + $(selector).nag('foo'); // $ExpectError + $(selector).nag({ foo: 'bar' }); // $ExpectError } import nag = require('semantic-ui-nag'); function test_module() { + nag; // $ExpectType Nag $.fn.nag = nag; } diff --git a/types/semantic-ui-popup/global.d.ts b/types/semantic-ui-popup/global.d.ts index 835d196089..f9504e1780 100644 --- a/types/semantic-ui-popup/global.d.ts +++ b/types/semantic-ui-popup/global.d.ts @@ -58,19 +58,66 @@ declare namespace SemanticUI { * Removes popup from the page */ (behavior: 'remove popup'): JQuery; - (behavior: 'setting', name: K, value?: undefined): PopupSettings[K]; - (behavior: 'setting', name: K, value: PopupSettings[K]): JQuery; - (behavior: 'setting', value: PopupSettings.Param): JQuery; - (settings?: PopupSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): PopupSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Popup Settings @@ -352,10 +399,12 @@ declare namespace SemanticUI { } namespace Popup { - interface DelaySettings extends Pick { } + type DelaySettings = DelaySettings.Param; namespace DelaySettings { - type Param = DelaySettings | object; + type Param = (Pick<_Impl, 'show'> | + Pick<_Impl, 'hide'>) & + Partial>; interface _Impl { show: number; @@ -363,10 +412,11 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'popup'>) & + Partial>; interface _Impl { /** @@ -376,10 +426,16 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + 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>; interface _Impl { /** @@ -409,10 +465,14 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -434,10 +494,15 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + 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>; interface _Impl { /** diff --git a/types/semantic-ui-popup/semantic-ui-popup-tests.ts b/types/semantic-ui-popup/semantic-ui-popup-tests.ts index b9cda09890..9b00a9dba8 100644 --- a/types/semantic-ui-popup/semantic-ui-popup-tests.ts +++ b/types/semantic-ui-popup/semantic-ui-popup-tests.ts @@ -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', '
') === $(); - $(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 + $(selector).popup('hide'); // $ExpectType JQuery + $(selector).popup('hide all'); // $ExpectType JQuery + $(selector).popup('get popup'); // $ExpectType JQuery + $(selector).popup('change content', '
'); // $ExpectType JQuery + $(selector).popup('toggle'); // $ExpectType JQuery + $(selector).popup('is visible'); // $ExpectType boolean + $(selector).popup('is hidden'); // $ExpectType boolean + $(selector).popup('exists'); // $ExpectType boolean + $(selector).popup('reposition'); // $ExpectType JQuery + $(selector).popup('set position', 'position'); // $ExpectType JQuery + $(selector).popup('destroy'); // $ExpectType JQuery + $(selector).popup('setting', 'debug', undefined); // $ExpectType boolean + $(selector).popup('setting', 'debug'); // $ExpectType boolean + $(selector).popup('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).popup('setting', { namespace: 'namespace', name: 'name', @@ -32,7 +33,8 @@ function test_popup() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).popup({ popup: $(), exclusive: true, @@ -64,34 +66,36 @@ function test_popup() { offset: 2, maxSearchDepth: 10, onCreate($module) { - this === $(); - $module === $(); + this; // $ExpectType JQuery + $module; // $ExpectType JQuery }, onRemove($module) { - this === $(); - $module === $(); + this; // $ExpectType JQuery + $module; // $ExpectType JQuery }, onShow($module) { - this === $(); - $module === $(); + this; // $ExpectType JQuery + $module; // $ExpectType JQuery + return false; }, onVisible($module) { - this === $(); - $module === $(); + this; // $ExpectType JQuery + $module; // $ExpectType JQuery }, onHide($module) { - this === $(); - $module === $(); + this; // $ExpectType JQuery + $module; // $ExpectType JQuery + return false; }, onHidden($module) { - this === $(); - $module === $(); + this; // $ExpectType JQuery + $module; // $ExpectType JQuery }, onUnplaceable($module) { - this === $(); - $module === $(); + this; // $ExpectType JQuery + $module; // $ExpectType JQuery }, variation: 'variation', content: 'content', @@ -121,12 +125,16 @@ function test_popup() { noTransition: 'noTransition', notFound: 'notFound' } - }) === $(); - $(selector).popup() === $(); + }); + $(selector).popup(); // $ExpectType JQuery + + $(selector).popup('foo'); // $ExpectError + $(selector).popup({ foo: 'bar' }); // $ExpectError } import popup = require('semantic-ui-popup'); function test_module() { + popup; // $ExpectType Popup $.fn.popup = popup; } diff --git a/types/semantic-ui-progress/global.d.ts b/types/semantic-ui-progress/global.d.ts index 06fe3b9892..da83f68dbe 100644 --- a/types/semantic-ui-progress/global.d.ts +++ b/types/semantic-ui-progress/global.d.ts @@ -123,19 +123,44 @@ declare namespace SemanticUI { */ (behavior: 'remove error'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): ProgressSettings[K]; - (behavior: 'setting', name: K, value: ProgressSettings[K]): JQuery; - (behavior: 'setting', value: ProgressSettings.Param): JQuery; - (settings?: ProgressSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): ProgressSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Progress Settings @@ -287,10 +312,12 @@ declare namespace SemanticUI { } namespace Progress { - interface RandomSettings extends Pick { } + type RandomSettings = RandomSettings.Param; namespace RandomSettings { - type Param = RandomSettings | object; + type Param = (Pick<_Impl, 'min'> | + Pick<_Impl, 'max'>) & + Partial>; interface _Impl { /** @@ -304,10 +331,16 @@ declare namespace SemanticUI { } } - interface TextSettings extends Pick { } + 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>; interface _Impl { /** @@ -337,10 +370,11 @@ declare namespace SemanticUI { } } - interface RegExpSettings extends Pick { } + type RegExpSettings = RegExpSettings.Param; namespace RegExpSettings { - type Param = RegExpSettings | object; + type Param = (Pick<_Impl, 'variable'>) & + Partial>; interface _Impl { /** @@ -350,10 +384,13 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'bar'> | + Pick<_Impl, 'label'> | + Pick<_Impl, 'progress'>) & + Partial>; interface _Impl { /** @@ -371,10 +408,13 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + type MetadataSettings = MetadataSettings.Param; namespace MetadataSettings { - type Param = MetadataSettings | object; + type Param = (Pick<_Impl, 'percent'> | + Pick<_Impl, 'total'> | + Pick<_Impl, 'value'>) & + Partial>; interface _Impl { /** @@ -392,10 +432,14 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -417,10 +461,12 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'method'> | + Pick<_Impl, 'nonNumeric'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-progress/semantic-ui-progress-tests.ts b/types/semantic-ui-progress/semantic-ui-progress-tests.ts index b950ed786f..747283828b 100644 --- a/types/semantic-ui-progress/semantic-ui-progress-tests.ts +++ b/types/semantic-ui-progress/semantic-ui-progress-tests.ts @@ -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 + $(selector).progress('set progress', 25); // $ExpectType JQuery + $(selector).progress('increment', 5); // $ExpectType JQuery + $(selector).progress('decrement', 2); // $ExpectType JQuery + $(selector).progress('update progress', 45); // $ExpectType JQuery + $(selector).progress('complete'); // $ExpectType JQuery + $(selector).progress('reset'); // $ExpectType JQuery + $(selector).progress('set total', 100); // $ExpectType JQuery + $(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 + $(selector).progress('set warning'); // $ExpectType JQuery + $(selector).progress('set success'); // $ExpectType JQuery + $(selector).progress('set error'); // $ExpectType JQuery + $(selector).progress('set duration', 4); // $ExpectType JQuery + $(selector).progress('set label', 'label'); // $ExpectType JQuery + $(selector).progress('set bar label', 'bar label'); // $ExpectType JQuery + $(selector).progress('remove active'); // $ExpectType JQuery + $(selector).progress('remove warning'); // $ExpectType JQuery + $(selector).progress('remove success'); // $ExpectType JQuery + $(selector).progress('remove error'); // $ExpectType JQuery + $(selector).progress('destroy'); // $ExpectType JQuery + $(selector).progress('setting', 'debug', undefined); // $ExpectType boolean + $(selector).progress('setting', 'debug'); // $ExpectType boolean + $(selector).progress('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).progress('setting', { namespace: 'namespace', name: 'name', @@ -50,7 +51,8 @@ function test_progress() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 + percent; // $ExpectType number + value; // $ExpectType number + total; // $ExpectType number }, onSuccess(total) { - this === $(); - total === 30; + this; // $ExpectType JQuery + total; // $ExpectType number }, onActive(value, total) { - this === $(); - value === 20; - total === 30; + this; // $ExpectType JQuery + value; // $ExpectType number + total; // $ExpectType number }, onError(value, total) { - this === $(); - value === 20; - total === 30; + this; // $ExpectType JQuery + value; // $ExpectType number + total; // $ExpectType number }, onWarning(value, total) { - this === $(); - value === 20; - total === 30; + this; // $ExpectType JQuery + 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 + + $(selector).progress('foo'); // $ExpectError + $(selector).progress({ foo: 'bar' }); // $ExpectError } import progress = require('semantic-ui-progress'); function test_module() { + progress; // $ExpectType Progress $.fn.progress = progress; } diff --git a/types/semantic-ui-rating/global.d.ts b/types/semantic-ui-rating/global.d.ts index 5fae40e3e3..e1f163ae0e 100644 --- a/types/semantic-ui-rating/global.d.ts +++ b/types/semantic-ui-rating/global.d.ts @@ -27,19 +27,33 @@ declare namespace SemanticUI { */ (behavior: 'clear rating'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): RatingSettings[K]; - (behavior: 'setting', name: K, value: RatingSettings[K]): JQuery; - (behavior: 'setting', value: RatingSettings.Param): JQuery; - (settings?: RatingSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): RatingSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Rating Settings @@ -134,10 +148,11 @@ declare namespace SemanticUI { } namespace Rating { - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'icon'>) & + Partial>; interface _Impl { /** @@ -147,10 +162,13 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { - type Param = ClassNameSettings | object; + type Param = (Pick<_Impl, 'active'> | + Pick<_Impl, 'hover'> | + Pick<_Impl, 'loading'>) & + Partial>; interface _Impl { /** @@ -168,10 +186,11 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'action'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-rating/semantic-ui-rating-tests.ts b/types/semantic-ui-rating/semantic-ui-rating-tests.ts index 8ea94b61aa..efc30f92d7 100644 --- a/types/semantic-ui-rating/semantic-ui-rating-tests.ts +++ b/types/semantic-ui-rating/semantic-ui-rating-tests.ts @@ -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 + $(selector).rating('get rating'); // $ExpectType number + $(selector).rating('disable'); // $ExpectType JQuery + $(selector).rating('enable'); // $ExpectType JQuery + $(selector).rating('clear rating'); // $ExpectType JQuery + $(selector).rating('destroy'); // $ExpectType JQuery + $(selector).rating('setting', 'debug', undefined); // $ExpectType boolean + $(selector).rating('setting', 'debug'); // $ExpectType boolean + $(selector).rating('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).rating('setting', { namespace: 'namespace', name: 'name', @@ -26,15 +27,16 @@ function test_rating() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).rating({ initialRating: 0, fireOnInit: false, clearable: false, interactive: true, onRate(value) { - this === $(); - value === 3; + this; // $ExpectType JQuery + value; // $ExpectType number }, selector: { icon: '.icon' @@ -47,12 +49,16 @@ function test_rating() { error: { action: 'action' } - }) === $(); - $(selector).rating() === $(); + }); + $(selector).rating(); // $ExpectType JQuery + + $(selector).rating('foo'); // $ExpectError + $(selector).rating({ foo: 'bar' }); // $ExpectError } import rating = require('semantic-ui-rating'); function test_module() { + rating; // $ExpectType Rating $.fn.rating = rating; } diff --git a/types/semantic-ui-search/global.d.ts b/types/semantic-ui-search/global.d.ts index bb3df65035..d5d265a4af 100644 --- a/types/semantic-ui-search/global.d.ts +++ b/types/semantic-ui-search/global.d.ts @@ -94,19 +94,52 @@ declare namespace SemanticUI { * Removes all events */ (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): SearchSettings[K]; - (behavior: 'setting', name: K, value: SearchSettings[K]): JQuery; - (behavior: 'setting', value: SearchSettings.Param): JQuery; - (settings?: SearchSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): SearchSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Behavior @@ -306,10 +339,21 @@ declare namespace SemanticUI { } namespace Search { - interface FieldsSettings extends Pick { } + 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>; interface _Impl { /** @@ -381,10 +425,14 @@ declare namespace SemanticUI { } } - interface TemplatesSettings extends Pick { } + 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>; interface _Impl { escape(string: string): string; @@ -394,10 +442,12 @@ declare namespace SemanticUI { } } - interface RegExpSettings extends Pick { } + type RegExpSettings = RegExpSettings.Param; namespace RegExpSettings { - type Param = RegExpSettings | object; + type Param = (Pick<_Impl, 'escape'> | + Pick<_Impl, 'beginsWith'>) & + Partial>; interface _Impl { /** @@ -411,10 +461,15 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + 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>; interface _Impl { /** @@ -440,10 +495,12 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + type MetadataSettings = MetadataSettings.Param; namespace MetadataSettings { - type Param = MetadataSettings | object; + type Param = (Pick<_Impl, 'cache'> | + Pick<_Impl, 'results'>) & + Partial>; interface _Impl { /** @@ -457,10 +514,15 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -486,10 +548,17 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + 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>; interface _Impl { /** diff --git a/types/semantic-ui-search/semantic-ui-search-tests.ts b/types/semantic-ui-search/semantic-ui-search-tests.ts index 86760f2832..25d964a5db 100644 --- a/types/semantic-ui-search/semantic-ui-search-tests.ts +++ b/types/semantic-ui-search/semantic-ui-search-tests.ts @@ -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 + $(selector).search('display message', 'text', 'type'); // $ExpectType JQuery + $(selector).search('cancel query'); // $ExpectType JQuery + $(selector).search('search local', 'query'); // $ExpectType JQuery + $(selector).search('has minimum characters'); // $ExpectType boolean + $(selector).search('search remote', 'query', () => { }); // $ExpectType JQuery + $(selector).search('search object', 'query', {}, ['searchField']); // $ExpectType any + $(selector).search('cancel query'); // $ExpectType JQuery + $(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 + $(selector).search('read cache', 'query'); // $ExpectType JQuery + $(selector).search('clear cache', 'query'); // $ExpectType JQuery + $(selector).search('write cache', 'query'); // $ExpectType JQuery + $(selector).search('add results', 'html'); // $ExpectType JQuery + $(selector).search('show results', () => { }); // $ExpectType JQuery + $(selector).search('hide results', () => { }); // $ExpectType JQuery + $(selector).search('generate results', {}); // $ExpectType JQuery + $(selector).search('destroy'); // $ExpectType JQuery + $(selector).search('setting', 'debug', undefined); // $ExpectType boolean + $(selector).search('setting', 'debug'); // $ExpectType boolean + $(selector).search('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).search('setting', { namespace: 'namespace', name: 'name', @@ -42,7 +43,8 @@ function test_search() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 }, onRequest(promise, xhr) { - promise === ({} as JQueryDeferred); - xhr === ({} as JQueryXHR); + promise; // $ExpectType Deferred + xhr; // $ExpectType jqXHR }, 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 + xhr; // $ExpectType jqXHR }, onComplete(response, element, xhr) { - response === ({} as any); - element === $(); - xhr === ({} as JQueryXHR); + response; // $ExpectType any + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, onFailure(response, element) { - response === ({} as any); - element === $(); + response; // $ExpectType any + element; // $ExpectType JQuery }, onError(errorMessage, element, xhr) { - errorMessage === ''; - element === $(); - xhr === ({} as JQueryXHR); + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, onAbort(errorMessage, element, xhr) { - errorMessage === ''; - element === $(); - xhr === ({} as JQueryXHR); + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, 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 + result; // $ExpectType any + response; // $ExpectType any + return false; }, onResultsAdd(html) { - this === $(); - html === 'html'; + this; // $ExpectType JQuery + html; // $ExpectType string + return false; }, onSearchQuery(query) { - this === $(); - query === 'query'; + this; // $ExpectType JQuery + query; // $ExpectType string }, onResults(response) { - this === $(); - response === {}; + this; // $ExpectType JQuery + response; // $ExpectType any }, onResultsOpen() { - this === $(); + this; // $ExpectType JQuery }, onResultsClose() { - this === $(); + this; // $ExpectType JQuery }, 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 + + $(selector).search('foo'); // $ExpectError + $(selector).search({ foo: 'bar' }); // $ExpectError } import search = require('semantic-ui-search'); function test_module() { + search; // $ExpectType Search $.fn.search = search; } diff --git a/types/semantic-ui-shape/global.d.ts b/types/semantic-ui-shape/global.d.ts index cfd6cc689e..37bdcc5af7 100644 --- a/types/semantic-ui-shape/global.d.ts +++ b/types/semantic-ui-shape/global.d.ts @@ -83,19 +83,33 @@ declare namespace SemanticUI { */ (behavior: 'get transform down'): Shape.Translation; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): ShapeSettings[K]; - (behavior: 'setting', name: K, value: ShapeSettings[K]): JQuery; - (behavior: 'setting', value: ShapeSettings.Param): JQuery; - (settings?: ShapeSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): ShapeSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Shape Settings @@ -198,10 +212,12 @@ declare namespace SemanticUI { transform: string; } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'sides'> | + Pick<_Impl, 'side'>) & + Partial>; interface _Impl { /** @@ -215,10 +231,14 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -240,10 +260,12 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'side'> | + Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-shape/semantic-ui-shape-tests.ts b/types/semantic-ui-shape/semantic-ui-shape-tests.ts index 994909085a..92cb5e6bef 100644 --- a/types/semantic-ui-shape/semantic-ui-shape-tests.ts +++ b/types/semantic-ui-shape/semantic-ui-shape-tests.ts @@ -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 + $(selector).shape('flip down'); // $ExpectType JQuery + $(selector).shape('flip right'); // $ExpectType JQuery + $(selector).shape('flip left'); // $ExpectType JQuery + $(selector).shape('flip over'); // $ExpectType JQuery + $(selector).shape('flip back'); // $ExpectType JQuery + $(selector).shape('set next side', $()); // $ExpectType JQuery + $(selector).shape('is animating'); // $ExpectType boolean + $(selector).shape('reset'); // $ExpectType JQuery + $(selector).shape('queue', 'animation'); // $ExpectType JQuery + $(selector).shape('repaint'); // $ExpectType JQuery + $(selector).shape('set default side'); // $ExpectType JQuery + $(selector).shape('set stage size'); // $ExpectType JQuery + $(selector).shape('refresh'); // $ExpectType JQuery + $(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 + $(selector).shape('setting', 'debug', undefined); // $ExpectType boolean + $(selector).shape('setting', 'debug'); // $ExpectType boolean + $(selector).shape('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).shape('setting', { namespace: 'namespace', name: 'name', @@ -40,16 +41,17 @@ function test_shape() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).shape({ duration: 700, width: 'next', height: 200, beforeChange() { - this === $(); + this; // $ExpectType JQuery }, onChange() { - this === $(); + this; // $ExpectType JQuery }, selector: { sides: 'sides', @@ -65,12 +67,16 @@ function test_shape() { side: 'side', method: 'method' } - }) === $(); - $(selector).shape() === $(); + }); + $(selector).shape(); // $ExpectType JQuery + + $(selector).shape('foo'); // $ExpectError + $(selector).shape({ foo: 'bar' }); // $ExpectError } import shape = require('semantic-ui-shape'); function test_module() { + shape; // $ExpectType Shape $.fn.shape = shape; } diff --git a/types/semantic-ui-sidebar/global.d.ts b/types/semantic-ui-sidebar/global.d.ts index 1217444f53..5ad0228182 100644 --- a/types/semantic-ui-sidebar/global.d.ts +++ b/types/semantic-ui-sidebar/global.d.ts @@ -55,19 +55,47 @@ declare namespace SemanticUI { */ (behavior: 'get transition event'): string; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): SidebarSettings[K]; - (behavior: 'setting', name: K, value: SidebarSettings[K]): JQuery; - (behavior: 'setting', value: SidebarSettings.Param): JQuery; - (settings?: SidebarSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): SidebarSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Behavior @@ -236,20 +264,26 @@ declare namespace SemanticUI { } namespace Sidebar { - interface DefaultTransitionSettings extends Pick { } + type DefaultTransitionSettings = DefaultTransitionSettings.Param; namespace DefaultTransitionSettings { - type Param = DefaultTransitionSettings | object; + type Param = (Pick<_Impl, 'computer'> | + Pick<_Impl, 'mobile'>) & + Partial>; interface _Impl { computer: ComputerSettings; mobile: MobileSettings; } - interface ComputerSettings extends Pick { } + 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>; interface _Impl { /** @@ -271,10 +305,14 @@ declare namespace SemanticUI { } } - interface MobileSettings extends Pick { } + 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>; interface _Impl { /** @@ -297,10 +335,21 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -350,10 +399,12 @@ declare namespace SemanticUI { } } - interface RegExpSettings extends Pick { } + type RegExpSettings = RegExpSettings.Param; namespace RegExpSettings { - type Param = RegExpSettings | object; + type Param = (Pick<_Impl, 'ios'> | + Pick<_Impl, 'mobile'>) & + Partial>; interface _Impl { /** @@ -367,10 +418,14 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + 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>; interface _Impl { /** @@ -392,10 +447,15 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + 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>; interface _Impl { /** diff --git a/types/semantic-ui-sidebar/semantic-ui-sidebar-tests.ts b/types/semantic-ui-sidebar/semantic-ui-sidebar-tests.ts index c98b73b47c..c747438052 100644 --- a/types/semantic-ui-sidebar/semantic-ui-sidebar-tests.ts +++ b/types/semantic-ui-sidebar/semantic-ui-sidebar-tests.ts @@ -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 + $(selector).sidebar('show'); // $ExpectType JQuery + $(selector).sidebar('hide'); // $ExpectType JQuery + $(selector).sidebar('toggle'); // $ExpectType JQuery + $(selector).sidebar('is visible'); // $ExpectType boolean + $(selector).sidebar('is hidden'); // $ExpectType boolean + $(selector).sidebar('push page'); // $ExpectType JQuery + $(selector).sidebar('get direction'); // $ExpectType string + $(selector).sidebar('pull page'); // $ExpectType JQuery + $(selector).sidebar('add body CSS'); // $ExpectType JQuery + $(selector).sidebar('remove body CSS'); // $ExpectType JQuery + $(selector).sidebar('get transition event'); // $ExpectType string + $(selector).sidebar('destroy'); // $ExpectType JQuery + $(selector).sidebar('setting', 'debug', undefined); // $ExpectType boolean + $(selector).sidebar('setting', 'debug'); // $ExpectType boolean + $(selector).sidebar('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).sidebar('setting', { namespace: 'namespace', name: 'name', @@ -33,7 +34,8 @@ function test_sidebar() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).sidebar({ context: $(), exclusive: false, @@ -62,19 +64,19 @@ function test_sidebar() { duration: 20, easing: 'easeInOutQuint', onVisible() { - this === $(); + this; // $ExpectType JQuery }, onShow() { - this === $(); + this; // $ExpectType JQuery }, onChange() { - this === $(); + this; // $ExpectType JQuery }, onHide() { - this === $(); + this; // $ExpectType JQuery }, onHidden() { - this === $(); + this; // $ExpectType JQuery }, className: { active: 'active', @@ -107,12 +109,16 @@ function test_sidebar() { overlay: 'overlay', notFound: 'notFound' } - }) === $(); - $(selector).sidebar() === $(); + }); + $(selector).sidebar(); // $ExpectType JQuery + + $(selector).sidebar('foo'); // $ExpectError + $(selector).sidebar({ foo: 'bar' }); // $ExpectError } import sidebar = require('semantic-ui-sidebar'); function test_module() { + sidebar; // $ExpectType Sidebar $.fn.sidebar = sidebar; } diff --git a/types/semantic-ui-site/global.d.ts b/types/semantic-ui-site/global.d.ts index 1cd7caa858..d03516fc9b 100644 --- a/types/semantic-ui-site/global.d.ts +++ b/types/semantic-ui-site/global.d.ts @@ -11,16 +11,25 @@ declare namespace SemanticUI { settings: SiteSettings; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): SiteSettings[K]; - (behavior: 'setting', name: K, value: SiteSettings[K]): JQuery; - (behavior: 'setting', value: SiteSettings.Param): JQuery; - (settings?: SiteSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): SiteSettings._Impl[K]; + (behavior: 'setting', name: K, value: SiteSettings._Impl[K]): JQuery; + (behavior: 'setting', value: SiteSettings): JQuery; + (settings?: SiteSettings): JQuery; } - interface SiteSettings extends Pick { } + 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>; interface _Impl { modules: string[]; @@ -68,10 +77,15 @@ declare namespace SemanticUI { } namespace Site { - interface NamespaceStubSettings extends Pick { } + 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>; interface _Impl { cache: any; diff --git a/types/semantic-ui-site/semantic-ui-site-tests.ts b/types/semantic-ui-site/semantic-ui-site-tests.ts index 0eaddfc5b2..a5fac3ff89 100644 --- a/types/semantic-ui-site/semantic-ui-site-tests.ts +++ b/types/semantic-ui-site/semantic-ui-site-tests.ts @@ -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 + $(selector).site('setting', 'debug', undefined); // $ExpectType boolean + $(selector).site('setting', 'debug'); // $ExpectType boolean + $(selector).site('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).site('setting', { namespace: 'namespace', name: 'name', @@ -27,7 +28,8 @@ function test_site() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).site({ modules: [ 'module1', @@ -41,12 +43,16 @@ function test_site() { section: {}, utilities: {} } - }) === $(); - $(selector).site() === $(); + }); + $(selector).site(); // $ExpectType JQuery + + $(selector).site('foo'); // $ExpectError + $(selector).site({ foo: 'bar' }); // $ExpectError } import site = require('semantic-ui-site'); function test_module() { + site; // $ExpectType Site $.fn.site = site; } diff --git a/types/semantic-ui-sticky/global.d.ts b/types/semantic-ui-sticky/global.d.ts index 683d1aafc7..220e57a011 100644 --- a/types/semantic-ui-sticky/global.d.ts +++ b/types/semantic-ui-sticky/global.d.ts @@ -11,19 +11,40 @@ declare namespace SemanticUI { */ (behavior: 'refresh'): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): StickySettings[K]; - (behavior: 'setting', name: K, value: StickySettings[K]): JQuery; - (behavior: 'setting', value: StickySettings.Param): JQuery; - (settings?: StickySettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): StickySettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Sticky Settings @@ -158,10 +179,15 @@ declare namespace SemanticUI { } namespace Sticky { - interface ClassNameSettings extends Pick { } + 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>; interface _Impl { /** @@ -187,10 +213,15 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + 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>; interface _Impl { /** diff --git a/types/semantic-ui-sticky/semantic-ui-sticky-tests.ts b/types/semantic-ui-sticky/semantic-ui-sticky-tests.ts index 0a3585f08d..fefad8870a 100644 --- a/types/semantic-ui-sticky/semantic-ui-sticky-tests.ts +++ b/types/semantic-ui-sticky/semantic-ui-sticky-tests.ts @@ -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 + $(selector).sticky('destroy'); // $ExpectType JQuery + $(selector).sticky('setting', 'debug', undefined); // $ExpectType boolean + $(selector).sticky('setting', 'debug'); // $ExpectType boolean + $(selector).sticky('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).sticky('setting', { namespace: 'namespace', name: 'name', @@ -22,7 +23,8 @@ function test_sticky() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).sticky({ pushing: false, jitter: 4, @@ -32,22 +34,22 @@ function test_sticky() { offset: 1, bottomOffset: 200, onReposition() { - this === $(); + this; // $ExpectType JQuery }, onScroll() { - this === $(); + this; // $ExpectType JQuery }, onStick() { - this === $(); + this; // $ExpectType JQuery }, onUnstick() { - this === $(); + this; // $ExpectType JQuery }, onTop() { - this === $(); + this; // $ExpectType JQuery }, onBottom() { - this === $(); + this; // $ExpectType JQuery }, className: { bound: 'bound', @@ -63,12 +65,16 @@ function test_sticky() { invalidContext: 'invalidContext', elementSize: 'elementSize' } - }) === $(); - $(selector).sticky() === $(); + }); + $(selector).sticky(); // $ExpectType JQuery + + $(selector).sticky('foo'); // $ExpectError + $(selector).sticky({ foo: 'bar' }); // $ExpectError } import sticky = require('semantic-ui-sticky'); function test_module() { + sticky; // $ExpectType Sticky $.fn.sticky = sticky; } diff --git a/types/semantic-ui-tab/global.d.ts b/types/semantic-ui-tab/global.d.ts index 7bd8aad4fc..5a31dffb18 100644 --- a/types/semantic-ui-tab/global.d.ts +++ b/types/semantic-ui-tab/global.d.ts @@ -40,19 +40,49 @@ declare namespace SemanticUI { */ (behavior: 'cache remove', path: string): JQuery; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): TabSettings[K]; - (behavior: 'setting', name: K, value: TabSettings[K]): JQuery; - (behavior: 'setting', value: TabSettings.Param): JQuery; - (settings?: TabSettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): TabSettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Tab Settings @@ -249,10 +279,11 @@ declare namespace SemanticUI { } namespace Tab { - interface TemplatesSettings extends Pick { } + type TemplatesSettings = TemplatesSettings.Param; namespace TemplatesSettings { - type Param = TemplatesSettings | object; + type Param = (Pick<_Impl, 'determineTitle'>) & + Partial>; interface _Impl { /** @@ -262,10 +293,12 @@ declare namespace SemanticUI { } } - interface SelectorSettings extends Pick { } + type SelectorSettings = SelectorSettings.Param; namespace SelectorSettings { - type Param = SelectorSettings | object; + type Param = (Pick<_Impl, 'tabs'> | + Pick<_Impl, 'parent'>) & + Partial>; interface _Impl { /** @@ -279,10 +312,13 @@ declare namespace SemanticUI { } } - interface MetadataSettings extends Pick { } + type MetadataSettings = MetadataSettings.Param; namespace MetadataSettings { - type Param = MetadataSettings | object; + type Param = (Pick<_Impl, 'tab'> | + Pick<_Impl, 'loaded'> | + Pick<_Impl, 'promise'>) & + Partial>; interface _Impl { /** @@ -300,10 +336,12 @@ declare namespace SemanticUI { } } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { - type Param = ClassNameSettings | object; + type Param = (Pick<_Impl, 'loading'> | + Pick<_Impl, 'active'>) & + Partial>; interface _Impl { /** @@ -317,10 +355,17 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + 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>; interface _Impl { /** diff --git a/types/semantic-ui-tab/semantic-ui-tab-tests.ts b/types/semantic-ui-tab/semantic-ui-tab-tests.ts index a3bbc096c4..f2bf6c874a 100644 --- a/types/semantic-ui-tab/semantic-ui-tab-tests.ts +++ b/types/semantic-ui-tab/semantic-ui-tab-tests.ts @@ -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 + $(selector).tab('set state', 'path'); // $ExpectType JQuery + $(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 + $(selector).tab('cache remove', 'path'); // $ExpectType JQuery + $(selector).tab('destroy'); // $ExpectType JQuery + $(selector).tab('setting', 'debug', undefined); // $ExpectType boolean + $(selector).tab('setting', 'debug'); // $ExpectType boolean + $(selector).tab('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).tab('setting', { namespace: 'namespace', name: 'name', @@ -28,7 +29,8 @@ function test_tab() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(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 }, onRequest(promise, xhr) { - promise === ({} as JQueryDeferred); - xhr === ({} as JQueryXHR); + promise; // $ExpectType Deferred + xhr; // $ExpectType jqXHR }, 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 + xhr; // $ExpectType jqXHR }, onComplete(response, element, xhr) { - response === ({} as any); - element === $(); - xhr === ({} as JQueryXHR); + response; // $ExpectType any + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, onFailure(response, element) { - response === ({} as any); - element === $(); + response; // $ExpectType any + element; // $ExpectType JQuery }, onError(errorMessage, element, xhr) { - errorMessage === ''; - element === $(); - xhr === ({} as JQueryXHR); + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, onAbort(errorMessage, element, xhr) { - errorMessage === ''; - element === $(); - xhr === ({} as JQueryXHR); + errorMessage; // $ExpectType string + element; // $ExpectType JQuery + xhr; // $ExpectType jqXHR }, 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 + tabPath; // $ExpectType string + parameterArray; // $ExpectType any[] + historyEvent; // $ExpectType any }, onLoad(tabPath, parameterArray, historyEvent) { - this === $(); - tabPath === 'tabPath'; - parameterArray === []; - historyEvent === {}; + this; // $ExpectType JQuery + tabPath; // $ExpectType string + parameterArray; // $ExpectType any[] + historyEvent; // $ExpectType any }, onRequest(tabPath) { - this === $(); - tabPath === 'tabPath'; + this; // $ExpectType JQuery + tabPath; // $ExpectType string }, onVisible(tabPath) { - this === $(); - tabPath === 'tabPath'; + this; // $ExpectType JQuery + 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 + + $(selector).tab('foo'); // $ExpectError + $(selector).tab({ foo: 'bar' }); // $ExpectError } import tab = require('semantic-ui-tab'); function test_module() { + tab; // $ExpectType Tab $.fn.tab = tab; } diff --git a/types/semantic-ui-transition/global.d.ts b/types/semantic-ui-transition/global.d.ts index 2ec4cf4ba4..48b530ad11 100644 --- a/types/semantic-ui-transition/global.d.ts +++ b/types/semantic-ui-transition/global.d.ts @@ -95,19 +95,41 @@ declare namespace SemanticUI { */ (behavior: 'is supported'): boolean; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): TransitionSettings[K]; - (behavior: 'setting', name: K, value: TransitionSettings[K]): JQuery; - (behavior: 'setting', value: TransitionSettings | object): JQuery; + (behavior: 'setting', name: K, value?: undefined): TransitionSettings._Impl[K]; + (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 { } + 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>; + interface _Impl { // region Transition Settings @@ -233,9 +255,20 @@ declare namespace SemanticUI { } namespace Transition { - interface ClassNameSettings extends Pick { } + 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>; + interface _Impl { /** * @default 'animating' @@ -276,9 +309,13 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { + type Param = (Pick<_Impl, 'noAnimation'> | + Pick<_Impl, 'method'>) & + Partial>; + interface _Impl { /** * @default 'There is no CSS animation matching the one you specified.' diff --git a/types/semantic-ui-transition/semantic-ui-transition-tests.ts b/types/semantic-ui-transition/semantic-ui-transition-tests.ts index a9b3208e8a..a010ba1437 100644 --- a/types/semantic-ui-transition/semantic-ui-transition-tests.ts +++ b/types/semantic-ui-transition/semantic-ui-transition-tests.ts @@ -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 + $(selector).transition('stop all'); // $ExpectType JQuery + $(selector).transition('clear queue'); // $ExpectType JQuery + $(selector).transition('show'); // $ExpectType JQuery + $(selector).transition('hide'); // $ExpectType JQuery + $(selector).transition('toggle'); // $ExpectType JQuery + $(selector).transition('force repaint'); // $ExpectType JQuery + $(selector).transition('repaint'); // $ExpectType JQuery + $(selector).transition('reset'); // $ExpectType JQuery + $(selector).transition('looping'); // $ExpectType JQuery + $(selector).transition('remove looping'); // $ExpectType JQuery + $(selector).transition('disable'); // $ExpectType JQuery + $(selector).transition('enable'); // $ExpectType JQuery + $(selector).transition('set duration', 10); // $ExpectType JQuery + $(selector).transition('save conditions'); // $ExpectType JQuery + $(selector).transition('restore conditions'); // $ExpectType JQuery + $(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 + $(selector).transition('setting', 'debug', undefined); // $ExpectType boolean + $(selector).transition('setting', 'debug'); // $ExpectType boolean + $(selector).transition('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(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 + // $ExpectType JQuery $(selector).transition({ animation: 'fade', interval: 200, @@ -55,16 +57,16 @@ function test_transition() { allowRepeats: true, queue: false, onShow() { - this === $(); + this; // $ExpectType JQuery }, onHide() { - this === $(); + this; // $ExpectType JQuery }, onStart() { - this === $(); + this; // $ExpectType JQuery }, onComplete() { - this === $(); + this; // $ExpectType JQuery }, className: { animating: 'animating', @@ -81,12 +83,15 @@ function test_transition() { noAnimation: 'noAnimation', method: 'method' } - }) === $(); - $(selector).transition() === $(); + }); + $(selector).transition(); // $ExpectType JQuery + + $(selector).transition({ foo: 'bar' }); // $ExpectError } import transition = require('semantic-ui-transition'); function test_module() { + transition; // $ExpectType Transition $.fn.transition = transition; } diff --git a/types/semantic-ui-visibility/global.d.ts b/types/semantic-ui-visibility/global.d.ts index fa735676c5..1f582bf257 100644 --- a/types/semantic-ui-visibility/global.d.ts +++ b/types/semantic-ui-visibility/global.d.ts @@ -39,19 +39,60 @@ declare namespace SemanticUI { */ (behavior: 'get screen size'): Visibility.ScreenSize; (behavior: 'destroy'): JQuery; - (behavior: 'setting', name: K, value?: undefined): VisibilitySettings[K]; - (behavior: 'setting', name: K, value: VisibilitySettings[K]): JQuery; - (behavior: 'setting', value: VisibilitySettings.Param): JQuery; - (settings?: VisibilitySettings.Param): JQuery; + (behavior: 'setting', name: K, value?: undefined): VisibilitySettings._Impl[K]; + (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 { } + 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>; interface _Impl { // region Functionality @@ -337,10 +378,11 @@ declare namespace SemanticUI { height: number; } - interface ClassNameSettings extends Pick { } + type ClassNameSettings = ClassNameSettings.Param; namespace ClassNameSettings { - type Param = ClassNameSettings | object; + type Param = (Pick<_Impl, 'fixed'>) & + Partial>; interface _Impl { /** @@ -350,10 +392,11 @@ declare namespace SemanticUI { } } - interface ErrorSettings extends Pick { } + type ErrorSettings = ErrorSettings.Param; namespace ErrorSettings { - type Param = ErrorSettings | object; + type Param = (Pick<_Impl, 'method'>) & + Partial>; interface _Impl { /** diff --git a/types/semantic-ui-visibility/semantic-ui-visibility-tests.ts b/types/semantic-ui-visibility/semantic-ui-visibility-tests.ts index 960eeb5215..44d8bb0361 100644 --- a/types/semantic-ui-visibility/semantic-ui-visibility-tests.ts +++ b/types/semantic-ui-visibility/semantic-ui-visibility-tests.ts @@ -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 + $(selector).visibility('enable callbacks'); // $ExpectType JQuery + $(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 + $(selector).visibility('setting', 'debug', undefined); // $ExpectType boolean + $(selector).visibility('setting', 'debug'); // $ExpectType boolean + $(selector).visibility('setting', 'debug', true); // $ExpectType JQuery + // $ExpectType JQuery $(selector).visibility('setting', { namespace: 'namespace', name: 'name', @@ -53,7 +30,8 @@ function test_visibility() { debug: true, performance: true, verbose: true - }) === $(); + }); + // $ExpectType JQuery $(selector).visibility({ once: false, continuous: true, @@ -71,78 +49,59 @@ function test_visibility() { transition: 'fade', duration: 5, onTopVisible() { - this === $(); + this; // $ExpectType JQuery }, onTopPassed() { - this === $(); + this; // $ExpectType JQuery }, onBottomVisible() { - this === $(); + this; // $ExpectType JQuery }, onPassing() { - this === $(); + this; // $ExpectType JQuery }, onBottomPassed() { - this === $(); + this; // $ExpectType JQuery }, onTopVisibleReverse() { - this === $(); + this; // $ExpectType JQuery }, onTopPassedReverse() { - this === $(); + this; // $ExpectType JQuery }, onBottomVisibleReverse() { - this === $(); + this; // $ExpectType JQuery }, onPassingReverse() { - this === $(); + this; // $ExpectType JQuery }, onBottomPassedReverse() { - this === $(); + this; // $ExpectType JQuery }, onOnScreen() { - this === $(); + this; // $ExpectType JQuery }, onOffScreen() { - this === $(); + this; // $ExpectType JQuery }, onLoad() { - this === $(); + this; // $ExpectType JQuery }, onAllLoaded() { - this === $(); + this; // $ExpectType JQuery }, onFixed() { - this === $(); + this; // $ExpectType JQuery }, onUnfixed() { - this === $(); + this; // $ExpectType JQuery }, 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 + calculations; // $ExpectType ElementCalculations }, onRefresh() { - this === $(); + this; // $ExpectType JQuery }, className: { fixed: 'fixed', @@ -150,12 +109,16 @@ function test_visibility() { error: { method: 'method' } - }) === $(); - $(selector).visibility() === $(); + }); + $(selector).visibility(); // $ExpectType JQuery + + $(selector).visibility('foo'); // $ExpectError + $(selector).visibility({ foo: 'bar' }); // $ExpectError } import visibility = require('semantic-ui-visibility'); function test_module() { + visibility; // $ExpectType Visibility $.fn.visibility = visibility; } diff --git a/types/tough-cookie/index.d.ts b/types/tough-cookie/index.d.ts index 9871e2579f..7aeb7b111f 100644 --- a/types/tough-cookie/index.d.ts +++ b/types/tough-cookie/index.d.ts @@ -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 { } - - namespace ParseOptions { - interface _Impl { - loose: boolean; - } + interface ParseOptions { + loose?: boolean; } - interface Properties extends Pick { } + 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 { } - - namespace Options { - interface _Impl { - rejectPublicSuffixes: boolean; - looseMode: boolean; - } + interface Options { + rejectPublicSuffixes?: boolean; + looseMode?: boolean; } - interface SetCookieOptions extends Pick { } - - 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 { } - - 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 {