From 18389908ad9a2438719c7286d00f86f7dbfdddd8 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Tue, 9 Aug 2022 16:19:53 +0200 Subject: [PATCH 1/2] chore: Convert `helpers.js` to TypeScript --- src/{helpers.js => helpers.ts} | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) rename src/{helpers.js => helpers.ts} (89%) diff --git a/src/helpers.js b/src/helpers.ts similarity index 89% rename from src/helpers.js rename to src/helpers.ts index ed356592..e9e16c38 100644 --- a/src/helpers.js +++ b/src/helpers.ts @@ -7,7 +7,7 @@ function jestFakeTimersAreEnabled() { if (typeof jest !== 'undefined' && jest !== null) { return ( // legacy timers - setTimeout._isMockFunction === true || + (setTimeout as any)._isMockFunction === true || // modern timers Object.prototype.hasOwnProperty.call(setTimeout, 'clock') ) @@ -23,7 +23,7 @@ function getDocument() { } return window.document } -function getWindowFromNode(node) { +function getWindowFromNode(node: any) { if (node.defaultView) { // node is document return node.defaultView @@ -60,11 +60,11 @@ function getWindowFromNode(node) { } } -function checkContainerType(container) { +function checkContainerType(container: unknown) { if ( !container || - !(typeof container.querySelector === 'function') || - !(typeof container.querySelectorAll === 'function') + !(typeof (container as any).querySelector === 'function') || + !(typeof (container as any).querySelectorAll === 'function') ) { throw new TypeError( `Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName( @@ -73,7 +73,7 @@ function checkContainerType(container) { ) } - function getTypeName(object) { + function getTypeName(object: unknown) { if (typeof object === 'object') { return object === null ? 'null' : object.constructor.name } From 0c4493045530a107d9a38432d890e80dc236a873 Mon Sep 17 00:00:00 2001 From: eps1lon Date: Tue, 9 Aug 2022 16:48:26 +0200 Subject: [PATCH 2/2] Just no --- package.json | 3 +++ src/helpers.ts | 1 + 2 files changed, 4 insertions(+) diff --git a/package.json b/package.json index 6881c899..a1cb7c03 100644 --- a/package.json +++ b/package.json @@ -65,6 +65,9 @@ "plugin:import/typescript" ], "rules": { + "@typescript-eslint/prefer-optional-chain": "off", + "@typescript-eslint/no-explicit-any": "off", + "@typescript-eslint/no-unsafe-member-access": "off", "@typescript-eslint/prefer-includes": "off", "import/prefer-default-export": "off", "import/no-unassigned-import": "off", diff --git a/src/helpers.ts b/src/helpers.ts index e9e16c38..5a068300 100644 --- a/src/helpers.ts +++ b/src/helpers.ts @@ -4,6 +4,7 @@ const TEXT_NODE = 3 function jestFakeTimersAreEnabled() { /* istanbul ignore else */ + // eslint-disable-next-line if (typeof jest !== 'undefined' && jest !== null) { return ( // legacy timers