Skip to content

Commit 8e9614b

Browse files
author
Rayat Rahman
committed
chore(types): Simply types in src/screen.ts
1 parent d34f235 commit 8e9614b

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/screen.ts

+3-9
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,16 @@ const logTestingPlaygroundURL = (element = getDocument().body) => {
4444
)
4545
}
4646

47-
const initialValue: {
48-
[key in keyof typeof queries | 'debug' | 'logTestingPlaygroundURL']?: Function
49-
} = {debug, logTestingPlaygroundURL}
47+
const initialValue = {debug, logTestingPlaygroundURL}
5048

5149
export const screen =
5250
typeof document !== 'undefined' && document.body // eslint-disable-line @typescript-eslint/no-unnecessary-condition
5351
? getQueriesForElement(document.body, queries, initialValue)
54-
: typedKeysOf(queries).reduce<typeof initialValue>((helpers, key) => {
55-
helpers[key] = () => {
52+
: Object.keys(queries).reduce((helpers, key) => {
53+
helpers[key as keyof typeof initialValue] = () => {
5654
throw new TypeError(
5755
'For queries bound to document.body a global document has to be available... Learn more: https://testing-library.com/s/screen-global-error',
5856
)
5957
}
6058
return helpers
6159
}, initialValue)
62-
63-
function typedKeysOf<O extends Object>(o: O) {
64-
return Object.keys(o) as Array<keyof O>
65-
}

0 commit comments

Comments
 (0)