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..a559f0a10d 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,13 @@ function test_nag() { noStorage: 'noStorage', method: 'method' } - }) === $(); - $(selector).nag() === $(); + }); + $(selector).nag(); // $ExpectType JQuery } import nag = require('semantic-ui-nag'); function test_module() { + nag; // $ExpectType Nag $.fn.nag = nag; }