Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added union type: SliderType to options.type #1163

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/js/core/Splide/Splide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { CREATED, DESTROYED, IDLE, STATES } from '../../constants/states';
import { FADE } from '../../constants/types';
import { EventInterface, EventInterfaceObject, State, StateObject } from '../../constructors';
import { Fade, Slide } from '../../transitions';
import { AnyFunction, ComponentConstructor, Components, EventMap, Options, SyncTarget } from '../../types';
import { AnyFunction, ComponentConstructor, Components, EventMap, Options, SliderType, SyncTarget } from '../../types';
import { addClass, assert, assign, empty, forOwn, getAttribute, isString, merge, query, slice } from '../../utils';
import { ARIA_LABEL, ARIA_LABELLEDBY } from '../../constants/attributes';

Expand Down Expand Up @@ -323,7 +323,7 @@ export class Splide {
*
* @return `true` if the type matches the current one, or otherwise `false`.
*/
is( type: string ): boolean {
is( type: SliderType ): boolean {
return this._o.type === type;
}

Expand Down
7 changes: 7 additions & 0 deletions src/js/types/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ export type AnyFunction = ( ...args: any[] ) => any;
*/
export type ComponentConstructor = ( Splide: Splide, Components: Components, options: Options ) => BaseComponent;

/**
* The type for a slider.
*
* @since 4.1.5
*/
export type SliderType = 'slide' | 'loop' | 'fade';

/**
* The interface for any component.
*
Expand Down
3 changes: 2 additions & 1 deletion src/js/types/options.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { I18N } from '../constants/i18n';
import { SliderType } from './general';


/**
Expand All @@ -13,7 +14,7 @@ export interface Options extends ResponsiveOptions {
* - 'loop' : A carousel slider
* - 'fade' : A slider with the fade transition. This does not support the perPage option.
*/
type?: string;
type?: SliderType;

/**
* The `role` attribute for the root element.
Expand Down