From df1b008f58a0826f6fc374fb7d326b11a531aac4 Mon Sep 17 00:00:00 2001 From: Nathanael Date: Wed, 2 Jan 2019 02:03:27 -0600 Subject: [PATCH 1/3] Added type definition for Wallop --- package.json | 2 +- types/wallop/index.d.ts | 112 +++++++++++++++++++++++++++++++++++ types/wallop/tsconfig.json | 24 ++++++++ types/wallop/tslint.json | 1 + types/wallop/wallop-tests.ts | 14 +++++ 5 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 types/wallop/index.d.ts create mode 100644 types/wallop/tsconfig.json create mode 100644 types/wallop/tslint.json create mode 100644 types/wallop/wallop-tests.ts diff --git a/package.json b/package.json index 7fc0358f27..4caeb0fe05 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "lint": "dtslint types" }, "devDependencies": { - "dtslint": "github:Microsoft/dtslint#production", + "dtslint": "^0.4.2", "types-publisher": "github:Microsoft/types-publisher#production" }, "dependencies": {} diff --git a/types/wallop/index.d.ts b/types/wallop/index.d.ts new file mode 100644 index 0000000000..fbc361d41c --- /dev/null +++ b/types/wallop/index.d.ts @@ -0,0 +1,112 @@ +// Type definitions for Wallop 2.4 +// Project: http://pedroduarte.me/wallop +// Definitions by: Nathanael McDaniel +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +export = Wallop; +export as namespace Wallop; + +declare namespace Wallop { + interface Options { + /** + * Override class for "next" button. + * + * @default 'Wallop-buttonNext' + */ + buttonNextClass?: string; + + /** + * Override class for "previous" button. + * + * @default 'Wallop-buttonPrevious' + */ + buttonPreviousClass?: string; + + /** + * Enable/disable carousel mode. + * + * @default true + */ + carousel?: boolean; + + /** + * Override class for current item. + * + * @default 'Wallop-item--current' + */ + currentItemClass?: string; + + /** + * Override class that hides next item. + * + * @default 'Wallop-item--hideNext' + */ + hideNextClass?: string; + + /** + * Override class that hides previous item. + * + * @default 'Wallop-item--hidePrevious' + */ + hidePreviousClass?: string; + + /** + * Override class for item. + * + * @default 'Wallop-item' + */ + itemClass?: string; + + /** + * Override class for item that will show next. + * + * @default 'Wallop-item--showNext' + */ + showNextClass?: string; + + /** + * Override class for item that will showed previously. + * + * @default 'Wallop-item--showPrevious' + */ + showPreviousClass?: string; + } +} + +declare class Wallop { + /** + * Implement new instance of Wallop. + */ + constructor(selector: Element, options?: Wallop.Options); + + /** + * Advances to the slide with the given index. + */ + goTo(index: number): Wallop; + + /** + * Advances to next slide. + */ + next(): Wallop; + + /** + * Unbinds method from custom event. + */ + off(eventName: string, callback: () => void): Wallop; + + /** + * Bind method to custom event. + */ + on(eventName: string, callback: () => void): Wallop; + + /** + * Returns to previous slide. + */ + previous(): Wallop; + + /** + * Resets current Wallop instance to defaults. + */ + reset(): Wallop; +} diff --git a/types/wallop/tsconfig.json b/types/wallop/tsconfig.json new file mode 100644 index 0000000000..d2728e47ed --- /dev/null +++ b/types/wallop/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "dom", + "es5" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "wallop-tests.ts" + ] +} diff --git a/types/wallop/tslint.json b/types/wallop/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/wallop/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" } diff --git a/types/wallop/wallop-tests.ts b/types/wallop/wallop-tests.ts new file mode 100644 index 0000000000..761d991df3 --- /dev/null +++ b/types/wallop/wallop-tests.ts @@ -0,0 +1,14 @@ +import Wallop = require('wallop'); + +const $element = document.createElement('div'); +$element.classList.add('.Wallop'); + +const slider = new Wallop($element); + +slider.goTo(0); // $ExpectType Wallop +slider.next(); // $ExpectType Wallop +slider.previous(); // $ExpectType Wallop +slider.reset(); // $ExpectType Wallop + +slider.on('change', () => { }); // $ExpectType Wallop +slider.off('change', () => { }); // $ExpectType Wallop From aee4551f5c1c4840727ed8cf3612271865d008bb Mon Sep 17 00:00:00 2001 From: Nathanael Date: Wed, 2 Jan 2019 02:07:34 -0600 Subject: [PATCH 2/3] Noticed accidental change of package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 4caeb0fe05..7fc0358f27 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "lint": "dtslint types" }, "devDependencies": { - "dtslint": "^0.4.2", + "dtslint": "github:Microsoft/dtslint#production", "types-publisher": "github:Microsoft/types-publisher#production" }, "dependencies": {} From 283edb4db7fa99ea33db2f7dc740865aa9dc9b25 Mon Sep 17 00:00:00 2001 From: Nathanael McDaniel Date: Wed, 2 Jan 2019 10:35:16 -0600 Subject: [PATCH 3/3] Update index.d.ts Updated project URL with GitHub repo. --- types/wallop/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/wallop/index.d.ts b/types/wallop/index.d.ts index fbc361d41c..a86bd4e99e 100644 --- a/types/wallop/index.d.ts +++ b/types/wallop/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for Wallop 2.4 -// Project: http://pedroduarte.me/wallop +// Project: https://github.com/peduarte/wallop // Definitions by: Nathanael McDaniel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3