mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-05 23:37:04 +00:00
[semantic-ui-shape] Different weak-type workaround.
This commit is contained in:
Vendored
+34
-12
@@ -83,19 +83,33 @@ declare namespace SemanticUI {
|
||||
*/
|
||||
(behavior: 'get transform down'): Shape.Translation;
|
||||
(behavior: 'destroy'): JQuery;
|
||||
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value?: undefined): ShapeSettings[K];
|
||||
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value: ShapeSettings[K]): JQuery;
|
||||
(behavior: 'setting', value: ShapeSettings.Param): JQuery;
|
||||
(settings?: ShapeSettings.Param): JQuery;
|
||||
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value?: undefined): ShapeSettings._Impl[K];
|
||||
<K extends keyof ShapeSettings>(behavior: 'setting', name: K, value: ShapeSettings._Impl[K]): JQuery;
|
||||
(behavior: 'setting', value: ShapeSettings): JQuery;
|
||||
(settings?: ShapeSettings): JQuery;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see {@link http://semantic-ui.com/modules/shape.html#/settings}
|
||||
*/
|
||||
interface ShapeSettings extends Pick<ShapeSettings._Impl, keyof ShapeSettings._Impl> { }
|
||||
type ShapeSettings = ShapeSettings.Param;
|
||||
|
||||
namespace ShapeSettings {
|
||||
type Param = ShapeSettings | object;
|
||||
type Param = (Pick<_Impl, 'duration'> |
|
||||
Pick<_Impl, 'width'> |
|
||||
Pick<_Impl, 'height'> |
|
||||
Pick<_Impl, 'beforeChange'> |
|
||||
Pick<_Impl, 'onChange'> |
|
||||
Pick<_Impl, 'selector'> |
|
||||
Pick<_Impl, 'className'> |
|
||||
Pick<_Impl, 'error'> |
|
||||
Pick<_Impl, 'namespace'> |
|
||||
Pick<_Impl, 'name'> |
|
||||
Pick<_Impl, 'silent'> |
|
||||
Pick<_Impl, 'debug'> |
|
||||
Pick<_Impl, 'performance'> |
|
||||
Pick<_Impl, 'verbose'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
// region Shape Settings
|
||||
@@ -198,10 +212,12 @@ declare namespace SemanticUI {
|
||||
transform: string;
|
||||
}
|
||||
|
||||
interface SelectorSettings extends Pick<SelectorSettings._Impl, keyof SelectorSettings._Impl> { }
|
||||
type SelectorSettings = SelectorSettings.Param;
|
||||
|
||||
namespace SelectorSettings {
|
||||
type Param = SelectorSettings | object;
|
||||
type Param = (Pick<_Impl, 'sides'> |
|
||||
Pick<_Impl, 'side'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -215,10 +231,14 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface ClassNameSettings extends Pick<ClassNameSettings._Impl, keyof ClassNameSettings._Impl> { }
|
||||
type ClassNameSettings = ClassNameSettings.Param;
|
||||
|
||||
namespace ClassNameSettings {
|
||||
type Param = ClassNameSettings | object;
|
||||
type Param = (Pick<_Impl, 'animating'> |
|
||||
Pick<_Impl, 'hidden'> |
|
||||
Pick<_Impl, 'loading'> |
|
||||
Pick<_Impl, 'active'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
@@ -240,10 +260,12 @@ declare namespace SemanticUI {
|
||||
}
|
||||
}
|
||||
|
||||
interface ErrorSettings extends Pick<ErrorSettings._Impl, keyof ErrorSettings._Impl> { }
|
||||
type ErrorSettings = ErrorSettings.Param;
|
||||
|
||||
namespace ErrorSettings {
|
||||
type Param = ErrorSettings | object;
|
||||
type Param = (Pick<_Impl, 'side'> |
|
||||
Pick<_Impl, 'method'>) &
|
||||
Partial<Pick<_Impl, keyof _Impl>>;
|
||||
|
||||
interface _Impl {
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
function test_shape_static() {
|
||||
$.fn.shape.settings.error.method = 'method';
|
||||
$.fn.shape.settings.error!.method = 'method';
|
||||
$.fn.shape.settings.namespace = 'namespace';
|
||||
$.fn.shape.settings.name = 'name';
|
||||
$.fn.shape.settings.silent = false;
|
||||
@@ -10,29 +10,30 @@ function test_shape_static() {
|
||||
|
||||
function test_shape() {
|
||||
const selector = '.ui.shape';
|
||||
$(selector).shape('flip up') === $();
|
||||
$(selector).shape('flip down') === $();
|
||||
$(selector).shape('flip right') === $();
|
||||
$(selector).shape('flip left') === $();
|
||||
$(selector).shape('flip over') === $();
|
||||
$(selector).shape('flip back') === $();
|
||||
$(selector).shape('set next side', $()) === $();
|
||||
$(selector).shape('is animating') === false;
|
||||
$(selector).shape('reset') === $();
|
||||
$(selector).shape('queue', 'animation') === $();
|
||||
$(selector).shape('repaint') === $();
|
||||
$(selector).shape('set default side') === $();
|
||||
$(selector).shape('set stage size') === $();
|
||||
$(selector).shape('refresh') === $();
|
||||
$(selector).shape('get transform down') === { transform: 'transform' };
|
||||
$(selector).shape('get transform left') === { transform: 'transform' };
|
||||
$(selector).shape('get transform right') === { transform: 'transform' };
|
||||
$(selector).shape('get transform up') === { transform: 'transform' };
|
||||
$(selector).shape('get transform down') === { transform: 'transform' };
|
||||
$(selector).shape('destroy') === $();
|
||||
$(selector).shape('setting', 'debug', undefined) === false;
|
||||
$(selector).shape('setting', 'debug') === false;
|
||||
$(selector).shape('setting', 'debug', true) === $();
|
||||
$(selector).shape('flip up'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('flip down'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('flip right'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('flip left'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('flip over'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('flip back'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('set next side', $()); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('is animating'); // $ExpectType boolean
|
||||
$(selector).shape('reset'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('queue', 'animation'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('repaint'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('set default side'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('set stage size'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('refresh'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('get transform down'); // $ExpectType Translation
|
||||
$(selector).shape('get transform left'); // $ExpectType Translation
|
||||
$(selector).shape('get transform right'); // $ExpectType Translation
|
||||
$(selector).shape('get transform up'); // $ExpectType Translation
|
||||
$(selector).shape('get transform down'); // $ExpectType Translation
|
||||
$(selector).shape('destroy'); // $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('setting', 'debug', undefined); // $ExpectType boolean
|
||||
$(selector).shape('setting', 'debug'); // $ExpectType boolean
|
||||
$(selector).shape('setting', 'debug', true); // $ExpectType JQuery<HTMLElement>
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape('setting', {
|
||||
namespace: 'namespace',
|
||||
name: 'name',
|
||||
@@ -40,16 +41,17 @@ function test_shape() {
|
||||
debug: true,
|
||||
performance: true,
|
||||
verbose: true
|
||||
}) === $();
|
||||
});
|
||||
// $ExpectType JQuery<HTMLElement>
|
||||
$(selector).shape({
|
||||
duration: 700,
|
||||
width: 'next',
|
||||
height: 200,
|
||||
beforeChange() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
onChange() {
|
||||
this === $();
|
||||
this; // $ExpectType JQuery<HTMLElement>
|
||||
},
|
||||
selector: {
|
||||
sides: 'sides',
|
||||
@@ -65,12 +67,16 @@ function test_shape() {
|
||||
side: 'side',
|
||||
method: 'method'
|
||||
}
|
||||
}) === $();
|
||||
$(selector).shape() === $();
|
||||
});
|
||||
$(selector).shape(); // $ExpectType JQuery<HTMLElement>
|
||||
|
||||
$(selector).shape('foo'); // $ExpectError
|
||||
$(selector).shape({ foo: 'bar' }); // $ExpectError
|
||||
}
|
||||
|
||||
import shape = require('semantic-ui-shape');
|
||||
|
||||
function test_module() {
|
||||
shape; // $ExpectType Shape
|
||||
$.fn.shape = shape;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user