From 4df19ddfc111464e5e78f280520fe3f5bce44f43 Mon Sep 17 00:00:00 2001 From: AndersonFriaca Date: Fri, 29 Jun 2018 13:14:16 -0400 Subject: [PATCH] Types for JQuery Gray --- types/jquery-gray/index.d.ts | 23 +++++++++++++++++++++++ types/jquery-gray/jquery-gray-tests.ts | 16 ++++++++++++++++ types/jquery-gray/tsconfig.json | 25 +++++++++++++++++++++++++ types/jquery-gray/tslint.json | 1 + 4 files changed, 65 insertions(+) create mode 100644 types/jquery-gray/index.d.ts create mode 100644 types/jquery-gray/jquery-gray-tests.ts create mode 100644 types/jquery-gray/tsconfig.json create mode 100644 types/jquery-gray/tslint.json diff --git a/types/jquery-gray/index.d.ts b/types/jquery-gray/index.d.ts new file mode 100644 index 0000000000..2d48831bc2 --- /dev/null +++ b/types/jquery-gray/index.d.ts @@ -0,0 +1,23 @@ +// Type definitions for JQuery Gray 1.6 +// Project: https://github.com/karlhorky/gray +// Definitions by: Anderson Friaça +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +/// + +export type Classes = Partial<{ + fade: string; +}>; + +export type Options = Partial<{ + fade: boolean; + classes: Classes; +}>; + +declare global { + interface JQuery { + gray(options?: Options): JQuery; + toggleClass(className: 'grayscale-off'): JQuery; + } +} diff --git a/types/jquery-gray/jquery-gray-tests.ts b/types/jquery-gray/jquery-gray-tests.ts new file mode 100644 index 0000000000..2e2027354f --- /dev/null +++ b/types/jquery-gray/jquery-gray-tests.ts @@ -0,0 +1,16 @@ +import { Options } from "jquery-gray"; + +// basic usage +$('.images').gray(); + +$('.images').toggleClass('grayscale-off'); + +// with options +const options: Options = { + fade: true, + classes: { + fade: 'grayscale-fade' + } +}; + +$('.images').gray(options); diff --git a/types/jquery-gray/tsconfig.json b/types/jquery-gray/tsconfig.json new file mode 100644 index 0000000000..81d0dced36 --- /dev/null +++ b/types/jquery-gray/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "esModuleInterop": true + }, + "files": [ + "index.d.ts", + "jquery-gray-tests.ts" + ] +} \ No newline at end of file diff --git a/types/jquery-gray/tslint.json b/types/jquery-gray/tslint.json new file mode 100644 index 0000000000..d04fe2e1fa --- /dev/null +++ b/types/jquery-gray/tslint.json @@ -0,0 +1 @@ +{"extends": "dtslint/dt.json"} \ No newline at end of file