mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
[semantic-ui-search] Different weak-type workaround.
This commit is contained in:
Vendored
+89
-20
@@ -94,19 +94,52 @@ declare namespace SemanticUI {
|
||||
* Removes all events
|
||||
*/
|
||||
(behavior: 'destroy'): JQuery;
|
||||
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value?: undefined): SearchSettings[K];
|
||||
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value: SearchSettings[K]): JQuery;
|
||||
(behavior: 'setting', value: SearchSettings.Param): JQuery;
|
||||
(settings?: SearchSettings.Param): JQuery;
|
||||
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value?: undefined): SearchSettings._Impl[K];
|
||||
<K extends keyof SearchSettings>(behavior: 'setting', name: K, value: SearchSettings._Impl[K]): JQuery;
|
||||
(behavior: 'setting', value: SearchSettings): JQuery;
|
||||
(settings?: SearchSettings): JQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link http://semantic-ui.com/modules/search.html#/settings}
|
||||
*/
|
||||
interface SearchSettings extends Pick<SearchSettings._Impl, keyof SearchSettings._Impl> { }
|
||||
type SearchSettings = SearchSettings.Param;
|
||||
|
||||
namespace SearchSettings {
|
||||
type Param = SearchSettings | object;
|
||||
type Param = (Pick<_Impl, 'apiSettings'> |
|
||||
Pick<_Impl, 'minCharacters'> |
|
||||
Pick<_Impl, 'transition'> |
|
||||
Pick<_Impl, 'duration'> |
|
||||
Pick<_Impl, 'maxResults'> |
|
||||
Pick<_Impl, 'cache'> |
|
||||
Pick<_Impl, 'source'> |
|
||||
Pick<_Impl, 'selectFirstResult'> |
|
||||
Pick<_Impl, 'showNoResults'> |
|
||||
Pick<_Impl, 'searchFullText'> |
|
||||
Pick<_Impl, 'fields'> |
|
||||
Pick<_Impl, 'searchFields'> |
|
||||
Pick<_Impl, 'hideDelay'> |
|
||||
Pick<_Impl, 'searchDelay'> |
|
||||
Pick<_Impl, 'easing'> |
|
||||
Pick<_Impl, 'onSelect'> |
|
||||
Pick<_Impl, 'onResultsAdd'> |
|
||||
Pick<_Impl, 'onSearchQuery'> |
|
||||
Pick<_Impl, 'onResults'> |
|
||||
Pick<_Impl, 'onResultsOpen'> |
|
||||
Pick<_Impl, 'onResultsClose'> |
|
||||
Pick<_Impl, 'templates'> |
|
||||
Pick<_Impl, 'regExp'> |
|
||||
Pick<_Impl, 'selector'> |
|
||||
Pick<_Impl, 'metadata'> |
|
||||
Pick<_Impl, 'className'> |
|
||||
Pick<_Impl, 'error'> |
|
||||
Pick<_Impl, 'namespace'> |
|
||||
Pick<_Impl, 'name'> |
|
||||
Pick<_Impl, 'silent'> |
|
||||
Pick<_Impl, 'debug'> |
|
||||
Pick<_Impl, 'performance'> |
|
||||
Pick<_Impl, 'verbose'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
// region Behavior
|
||||
@@ -306,10 +339,21 @@ declare namespace SemanticUI {
|
||||
}
|
||||
|
||||
namespace Search {
|
||||
interface FieldsSettings extends Pick<FieldsSettings._Impl, keyof FieldsSettings._Impl> { }
|
||||
type FieldsSettings = FieldsSettings.Param;
|
||||
|
||||
namespace FieldsSettings {
|
||||
type Param = FieldsSettings | object;
|
||||
type Param = (Pick<_Impl, 'categories'> |
|
||||
Pick<_Impl, 'categoryName'> |
|
||||
Pick<_Impl, 'categoryResults'> |
|
||||
Pick<_Impl, 'description'> |
|
||||
Pick<_Impl, 'image'> |
|
||||
Pick<_Impl, 'price'> |
|
||||
Pick<_Impl, 'results'> |
|
||||
Pick<_Impl, 'title'> |
|
||||
Pick<_Impl, 'action'> |
|
||||
Pick<_Impl, 'actionText'> |
|
||||
Pick<_Impl, 'actionURL'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -381,10 +425,14 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface TemplatesSettings extends Pick<TemplatesSettings._Impl, keyof TemplatesSettings._Impl> { }
|
||||
type TemplatesSettings = TemplatesSettings.Param;
|
||||
|
||||
namespace TemplatesSettings {
|
||||
type Param = TemplatesSettings | object;
|
||||
type Param = (Pick<_Impl, 'escape'> |
|
||||
Pick<_Impl, 'message'> |
|
||||
Pick<_Impl, 'category'> |
|
||||
Pick<_Impl, 'standard'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
escape(string: string): string;
|
||||
@@ -394,10 +442,12 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface RegExpSettings extends Pick<RegExpSettings._Impl, keyof RegExpSettings._Impl> { }
|
||||
type RegExpSettings = RegExpSettings.Param;
|
||||
|
||||
namespace RegExpSettings {
|
||||
type Param = RegExpSettings | object;
|
||||
type Param = (Pick<_Impl, 'escape'> |
|
||||
Pick<_Impl, 'beginsWith'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -411,10 +461,15 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
|
||||
type SelectorSettings = SelectorSettings.Param;
|
||||
|
||||
namespace SelectorSettings {
|
||||
type Param = SelectorSettings | object;
|
||||
type Param = (Pick<_Impl, 'prompt'> |
|
||||
Pick<_Impl, 'searchButton'> |
|
||||
Pick<_Impl, 'results'> |
|
||||
Pick<_Impl, 'category'> |
|
||||
Pick<_Impl, 'result'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -440,10 +495,12 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface MetadataSettings extends Pick<MetadataSettings._Impl, keyof MetadataSettings._Impl> { }
|
||||
type MetadataSettings = MetadataSettings.Param;
|
||||
|
||||
namespace MetadataSettings {
|
||||
type Param = MetadataSettings | object;
|
||||
type Param = (Pick<_Impl, 'cache'> |
|
||||
Pick<_Impl, 'results'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -457,10 +514,15 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
|
||||
type ClassNameSettings = ClassNameSettings.Param;
|
||||
|
||||
namespace ClassNameSettings {
|
||||
type Param = ClassNameSettings | object;
|
||||
type Param = (Pick<_Impl, 'active'> |
|
||||
Pick<_Impl, 'empty'> |
|
||||
Pick<_Impl, 'focus'> |
|
||||
Pick<_Impl, 'loading'> |
|
||||
Pick<_Impl, 'pressed'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -486,10 +548,17 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
|
||||
type ErrorSettings = ErrorSettings.Param;
|
||||
|
||||
namespace ErrorSettings {
|
||||
type Param = ErrorSettings | object;
|
||||
type Param = (Pick<_Impl, 'source'> |
|
||||
Pick<_Impl, 'noResults'> |
|
||||
Pick<_Impl, 'logging'> |
|
||||
Pick<_Impl, 'noTemplate'> |
|
||||
Pick<_Impl, 'serverError'> |
|
||||
Pick<_Impl, 'maxResults'> |
|
||||
Pick<_Impl, 'method'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function test_search_static() {
|
||||
$.fn.search.settings.error.method = 'method';
|
||||
$.fn.search.settings.error!.method = 'method';
|
||||
$.fn.search.settings.namespace = 'namespace';
|
||||
$.fn.search.settings.name = 'name';
|
||||
$.fn.search.settings.silent = false;
|
||||
@@ -10,31 +10,32 @@ function test_search_static() {
|
||||
|
||||
function test_search() {
|
||||
const selector = '.ui.search';
|
||||
$(selector).search('query', () => { }) === $();
|
||||
$(selector).search('display message', 'text', 'type') === $();
|
||||
$(selector).search('cancel query') === $();
|
||||
$(selector).search('search local', 'query') === $();
|
||||
$(selector).search('has minimum characters') === true;
|
||||
$(selector).search('search remote', 'query', () => { }) === $();
|
||||
$(selector).search('search object', 'query', {}, ['searchField']) === {};
|
||||
$(selector).search('cancel query') === $();
|
||||
$(selector).search('is focused') === false;
|
||||
$(selector).search('is visible') === true;
|
||||
$(selector).search('is empty') === false;
|
||||
$(selector).search('get value') === {};
|
||||
$(selector).search('get result', 'value') === {};
|
||||
$(selector).search('set value', 'value') === $();
|
||||
$(selector).search('read cache', 'query') === $();
|
||||
$(selector).search('clear cache', 'query') === $();
|
||||
$(selector).search('write cache', 'query') === $();
|
||||
$(selector).search('add results', 'html') === $();
|
||||
$(selector).search('show results', () => { }) === $();
|
||||
$(selector).search('hide results', () => { }) === $();
|
||||
$(selector).search('generate results', {}) === $();
|
||||
$(selector).search('destroy') === $();
|
||||
$(selector).search('setting', 'debug', undefined) === false;
|
||||
$(selector).search('setting', 'debug') === false;
|
||||
$(selector).search('setting', 'debug', true) === $();
|
||||
$(selector).search('query', () => { }); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('display message', 'text', 'type'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('cancel query'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('search local', 'query'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('has minimum characters'); // $ExpectType boolean
|
||||
$(selector).search('search remote', 'query', () => { }); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('search object', 'query', {}, ['searchField']); // $ExpectType any
|
||||
$(selector).search('cancel query'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('is focused'); // $ExpectType boolean
|
||||
$(selector).search('is visible'); // $ExpectType boolean
|
||||
$(selector).search('is empty'); // $ExpectType boolean
|
||||
$(selector).search('get value'); // $ExpectType any
|
||||
$(selector).search('get result', 'value'); // $ExpectType any
|
||||
$(selector).search('set value', 'value'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('read cache', 'query'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('clear cache', 'query'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('write cache', 'query'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('add results', 'html'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('show results', () => { }); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('hide results', () => { }); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('generate results', {}); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('destroy'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('setting', 'debug', undefined); // $ExpectType boolean
|
||||
$(selector).search('setting', 'debug'); // $ExpectType boolean
|
||||
$(selector).search('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search('setting', {
|
||||
namespace: 'namespace',
|
||||
name: 'name',
|
||||
@@ -42,7 +43,8 @@ function test_search() {
|
||||
debug: true,
|
||||
performance: true,
|
||||
verbose: true
|
||||
}) === $();
|
||||
});
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(selector).search({
|
||||
apiSettings: {
|
||||
on: 'on',
|
||||
@@ -62,56 +64,58 @@ function test_search() {
|
||||
urlData: false,
|
||||
response: false,
|
||||
responseAsync(settings, callback) {
|
||||
settings === ({} as SemanticUI.ApiSettings);
|
||||
callback === ((response: any) => { });
|
||||
settings; // $ExpectType Param
|
||||
callback; // $ExpectType (response: any) => void
|
||||
},
|
||||
mockResponse: false,
|
||||
mockResponseAsync(settings, callback) {
|
||||
settings === ({} as SemanticUI.ApiSettings);
|
||||
callback === ((response: any) => { });
|
||||
settings; // $ExpectType Param
|
||||
callback; // $ExpectType (response: any) => void
|
||||
},
|
||||
method: 'post',
|
||||
dataType: 'xml',
|
||||
data: {},
|
||||
beforeSend(settings) {
|
||||
settings === ({} as SemanticUI.ApiSettings);
|
||||
settings; // $ExpectType Param
|
||||
},
|
||||
beforeXHR(xhrObject) {
|
||||
xhrObject === ({} as JQueryXHR);
|
||||
xhrObject; // $ExpectType jqXHR<any>
|
||||
},
|
||||
onRequest(promise, xhr) {
|
||||
promise === ({} as JQueryDeferred<any>);
|
||||
xhr === ({} as JQueryXHR);
|
||||
promise; // $ExpectType Deferred<any, any, any>
|
||||
xhr; // $ExpectType jqXHR<any>
|
||||
},
|
||||
onResponse(response) {
|
||||
response === ({} as any);
|
||||
response; // $ExpectType any
|
||||
},
|
||||
successTest(response) {
|
||||
return response === ({} as any);
|
||||
response; // $ExpectType any
|
||||
|
||||
return false;
|
||||
},
|
||||
onSuccess(response, element, xhr) {
|
||||
response === ({} as any);
|
||||
element === $();
|
||||
xhr === ({} as JQueryXHR);
|
||||
response; // $ExpectType any
|
||||
element; // $ExpectType JQuery<HTMLElement>
|
||||
xhr; // $ExpectType jqXHR<any>
|
||||
},
|
||||
onComplete(response, element, xhr) {
|
||||
response === ({} as any);
|
||||
element === $();
|
||||
xhr === ({} as JQueryXHR);
|
||||
response; // $ExpectType any
|
||||
element; // $ExpectType JQuery<HTMLElement>
|
||||
xhr; // $ExpectType jqXHR<any>
|
||||
},
|
||||
onFailure(response, element) {
|
||||
response === ({} as any);
|
||||
element === $();
|
||||
response; // $ExpectType any
|
||||
element; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onError(errorMessage, element, xhr) {
|
||||
errorMessage === '';
|
||||
element === $();
|
||||
xhr === ({} as JQueryXHR);
|
||||
errorMessage; // $ExpectType string
|
||||
element; // $ExpectType JQuery<HTMLElement>
|
||||
xhr; // $ExpectType jqXHR<any>
|
||||
},
|
||||
onAbort(errorMessage, element, xhr) {
|
||||
errorMessage === '';
|
||||
element === $();
|
||||
xhr === ({} as JQueryXHR);
|
||||
errorMessage; // $ExpectType string
|
||||
element; // $ExpectType JQuery<HTMLElement>
|
||||
xhr; // $ExpectType jqXHR<any>
|
||||
},
|
||||
regExp: {
|
||||
required: /{\$*[A-z0-9]+}/g,
|
||||
@@ -175,41 +179,52 @@ function test_search() {
|
||||
searchDelay: 10,
|
||||
easing: 'easeOutExpo',
|
||||
onSelect(result, response) {
|
||||
this === $();
|
||||
result === {};
|
||||
response === {};
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
result; // $ExpectType any
|
||||
response; // $ExpectType any
|
||||
|
||||
return false;
|
||||
},
|
||||
onResultsAdd(html) {
|
||||
this === $();
|
||||
html === 'html';
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
html; // $ExpectType string
|
||||
|
||||
return false;
|
||||
},
|
||||
onSearchQuery(query) {
|
||||
this === $();
|
||||
query === 'query';
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
query; // $ExpectType string
|
||||
},
|
||||
onResults(response) {
|
||||
this === $();
|
||||
response === {};
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
response; // $ExpectType any
|
||||
},
|
||||
onResultsOpen() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onResultsClose() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
templates: {
|
||||
escape(string) {
|
||||
return string;
|
||||
string; // $ExpectType string
|
||||
|
||||
return 'escape';
|
||||
},
|
||||
message(message, type) {
|
||||
return message + type;
|
||||
message; // $ExpectType string
|
||||
type; // $ExpectType string
|
||||
|
||||
return 'message';
|
||||
},
|
||||
category(response) {
|
||||
response; // $ExpectType any
|
||||
|
||||
return 'category';
|
||||
},
|
||||
standard(response) {
|
||||
response; // $ExpectType any
|
||||
|
||||
return 'standard';
|
||||
}
|
||||
},
|
||||
@@ -244,12 +259,16 @@ function test_search() {
|
||||
maxResults: 'maxResults',
|
||||
method: 'method'
|
||||
}
|
||||
}) === $();
|
||||
$(selector).search() === $();
|
||||
});
|
||||
$(selector).search(); // $ExpectType JQuery<HTMLElement>
|
||||
|
||||
$(selector).search('foo'); // $ExpectError
|
||||
$(selector).search({ foo: 'bar' }); // $ExpectError
|
||||
}
|
||||
|
||||
import search = require('semantic-ui-search');
|
||||
|
||||
function test_module() {
|
||||
search; // $ExpectType Search
|
||||
$.fn.search = search;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user