Skip to content

Commit a21bb3d

Browse files
authored
chore: convert helpers.js to TypeScript (#1156)
1 parent d50a967 commit a21bb3d

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@
6565
"plugin:import/typescript"
6666
],
6767
"rules": {
68+
"@typescript-eslint/prefer-optional-chain": "off",
69+
"@typescript-eslint/no-explicit-any": "off",
70+
"@typescript-eslint/no-unsafe-member-access": "off",
6871
"@typescript-eslint/prefer-includes": "off",
6972
"import/prefer-default-export": "off",
7073
"import/no-unassigned-import": "off",

src/helpers.js renamed to src/helpers.ts

+7-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ const TEXT_NODE = 3
44

55
function jestFakeTimersAreEnabled() {
66
/* istanbul ignore else */
7+
// eslint-disable-next-line
78
if (typeof jest !== 'undefined' && jest !== null) {
89
return (
910
// legacy timers
10-
setTimeout._isMockFunction === true ||
11+
(setTimeout as any)._isMockFunction === true ||
1112
// modern timers
1213
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
1314
)
@@ -23,7 +24,7 @@ function getDocument() {
2324
}
2425
return window.document
2526
}
26-
function getWindowFromNode(node) {
27+
function getWindowFromNode(node: any) {
2728
if (node.defaultView) {
2829
// node is document
2930
return node.defaultView
@@ -60,11 +61,11 @@ function getWindowFromNode(node) {
6061
}
6162
}
6263

63-
function checkContainerType(container) {
64+
function checkContainerType(container: unknown) {
6465
if (
6566
!container ||
66-
!(typeof container.querySelector === 'function') ||
67-
!(typeof container.querySelectorAll === 'function')
67+
!(typeof (container as any).querySelector === 'function') ||
68+
!(typeof (container as any).querySelectorAll === 'function')
6869
) {
6970
throw new TypeError(
7071
`Expected container to be an Element, a Document or a DocumentFragment but got ${getTypeName(
@@ -73,7 +74,7 @@ function checkContainerType(container) {
7374
)
7475
}
7576

76-
function getTypeName(object) {
77+
function getTypeName(object: unknown) {
7778
if (typeof object === 'object') {
7879
return object === null ? 'null' : object.constructor.name
7980
}

0 commit comments

Comments
 (0)