From ab7503f6eb531ba738980049970dc5006514c381 Mon Sep 17 00:00:00 2001 From: Michael Swiger Date: Fri, 21 Sep 2018 01:23:46 -0700 Subject: [PATCH 1/3] Add typings for tabbable --- types/tabbable/index.d.ts | 14 ++++++++++++++ types/tabbable/tabbable-tests.ts | 8 ++++++++ types/tabbable/tsconfig.json | 24 ++++++++++++++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 types/tabbable/index.d.ts create mode 100644 types/tabbable/tabbable-tests.ts create mode 100644 types/tabbable/tsconfig.json diff --git a/types/tabbable/index.d.ts b/types/tabbable/index.d.ts new file mode 100644 index 0000000000..f1c76ea366 --- /dev/null +++ b/types/tabbable/index.d.ts @@ -0,0 +1,14 @@ +// Type definitions for tabbable v3.1.1 +// Project: https://github.com/davidtheclark/tabbable +// Definitions by: Michael Swiger +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +declare function T(el: Element | Document, options?: T.Options): HTMLElement[]; + +declare namespace T { + interface Options { + includeContainer?: boolean; + } +} + +export = T; \ No newline at end of file diff --git a/types/tabbable/tabbable-tests.ts b/types/tabbable/tabbable-tests.ts new file mode 100644 index 0000000000..52ad379256 --- /dev/null +++ b/types/tabbable/tabbable-tests.ts @@ -0,0 +1,8 @@ +import tabbable = require('tabbable'); + +var el = document.createElement('div'); +tabbable(el); +tabbable(el, { includeContainer: true }); + +tabbable(document); +tabbable(document, { includeContainer: true }); diff --git a/types/tabbable/tsconfig.json b/types/tabbable/tsconfig.json new file mode 100644 index 0000000000..859be5eba0 --- /dev/null +++ b/types/tabbable/tsconfig.json @@ -0,0 +1,24 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6", + "dom" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "tabbable-tests.ts" + ] +} \ No newline at end of file From 04bf44a2839c25e09f19c295edb64e12684c8649 Mon Sep 17 00:00:00 2001 From: Michael Swiger Date: Fri, 21 Sep 2018 01:33:13 -0700 Subject: [PATCH 2/3] Fix lint/test errors --- types/tabbable/index.d.ts | 4 ++-- types/tabbable/tabbable-tests.ts | 2 +- types/tabbable/tslint.json | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) create mode 100644 types/tabbable/tslint.json diff --git a/types/tabbable/index.d.ts b/types/tabbable/index.d.ts index f1c76ea366..2226240ce3 100644 --- a/types/tabbable/index.d.ts +++ b/types/tabbable/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for tabbable v3.1.1 +// Type definitions for tabbable 3.1 // Project: https://github.com/davidtheclark/tabbable // Definitions by: Michael Swiger // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -11,4 +11,4 @@ declare namespace T { } } -export = T; \ No newline at end of file +export = T; diff --git a/types/tabbable/tabbable-tests.ts b/types/tabbable/tabbable-tests.ts index 52ad379256..9897c0823c 100644 --- a/types/tabbable/tabbable-tests.ts +++ b/types/tabbable/tabbable-tests.ts @@ -1,6 +1,6 @@ import tabbable = require('tabbable'); -var el = document.createElement('div'); +const el = document.createElement('div'); tabbable(el); tabbable(el, { includeContainer: true }); diff --git a/types/tabbable/tslint.json b/types/tabbable/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/tabbable/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +} From cabd19f21ee70f0517651b4ab4ba71d851b50cfa Mon Sep 17 00:00:00 2001 From: Michael Swiger Date: Fri, 21 Sep 2018 02:48:06 -0700 Subject: [PATCH 3/3] Add missing isTabbable and isFocusable functions --- types/tabbable/index.d.ts | 4 ++++ types/tabbable/tabbable-tests.ts | 3 +++ types/tabbable/tsconfig.json | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/types/tabbable/index.d.ts b/types/tabbable/index.d.ts index 2226240ce3..abff53bb25 100644 --- a/types/tabbable/index.d.ts +++ b/types/tabbable/index.d.ts @@ -9,6 +9,10 @@ declare namespace T { interface Options { includeContainer?: boolean; } + + function isTabbable(el: HTMLElement): boolean; + + function isFocusable(el: HTMLElement): boolean; } export = T; diff --git a/types/tabbable/tabbable-tests.ts b/types/tabbable/tabbable-tests.ts index 9897c0823c..a64032a54f 100644 --- a/types/tabbable/tabbable-tests.ts +++ b/types/tabbable/tabbable-tests.ts @@ -6,3 +6,6 @@ tabbable(el, { includeContainer: true }); tabbable(document); tabbable(document, { includeContainer: true }); + +tabbable.isTabbable(el); +tabbable.isFocusable(el); diff --git a/types/tabbable/tsconfig.json b/types/tabbable/tsconfig.json index 859be5eba0..b40321a02a 100644 --- a/types/tabbable/tsconfig.json +++ b/types/tabbable/tsconfig.json @@ -21,4 +21,4 @@ "index.d.ts", "tabbable-tests.ts" ] -} \ No newline at end of file +}