Skip to content

Commit 2da06c8

Browse files
committed
chore: use types from old folder
1 parent 8c82991 commit 2da06c8

File tree

8 files changed

+33
-58
lines changed

8 files changed

+33
-58
lines changed

src/config.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,6 @@
1+
import {Config, ConfigFn} from '../types/config'
2+
import {Callback} from '../types/utils'
13
import {prettyDOM} from './pretty-dom'
2-
import {Callback} from './types'
3-
4-
export interface Config {
5-
testIdAttribute: string
6-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
7-
asyncWrapper(cb: (...args: any[]) => any): Promise<any>
8-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
9-
eventWrapper(cb: (...args: any[]) => any): void
10-
asyncUtilTimeout: number
11-
computedStyleSupportsPseudoElements: boolean
12-
defaultHidden: boolean
13-
showOriginalStackTrace: boolean
14-
throwSuggestions: boolean
15-
getElementError: (message: string | null, container: Element) => Error
16-
}
17-
18-
export interface ConfigFn {
19-
(existingConfig: Config): Partial<Config>
20-
}
214

225
interface InternalConfig {
236
_disableExpensiveErrorDiagnostics: boolean

src/matches.ts

Lines changed: 7 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,10 @@
1-
import {ARIARole} from 'aria-query'
2-
import {Nullish} from './types'
3-
4-
export type ByRoleMatcher = ARIARole | MatcherFunction | {}
5-
6-
export type Matcher = MatcherFunction | RegExp | string
7-
8-
export type MatcherFunction = (
9-
content: string,
10-
element: Nullish<Element>,
11-
) => boolean
12-
13-
export type NormalizerFn = (text: string) => string
14-
15-
export interface DefaultNormalizerOptions {
16-
trim?: boolean
17-
collapseWhitespace?: boolean
18-
}
19-
20-
export interface MatcherOptions {
21-
exact?: boolean
22-
/** Use normalizer with getDefaultNormalizer instead */
23-
trim?: boolean
24-
/** Use normalizer with getDefaultNormalizer instead */
25-
collapseWhitespace?: boolean
26-
normalizer?: NormalizerFn
27-
/** suppress suggestions for a specific query */
28-
suggest?: boolean
29-
}
30-
31-
export type NormalizerOptions = DefaultNormalizerOptions & {
32-
normalizer?: NormalizerFn
33-
}
1+
import {
2+
Matcher,
3+
NormalizerFn,
4+
NormalizerOptions,
5+
DefaultNormalizerOptions,
6+
} from '../types'
7+
import {Nullish} from '../types/utils'
348

359
function assertNotNullOrUndefined<T>(
3610
matcher: T,

src/types.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/jest.config.dom.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const baseConfig = require('kcd-scripts/jest')
33

44
module.exports = {
55
...baseConfig,
6+
moduleFileExtensions: [...baseConfig.moduleFileExtensions, 'd.ts'],
7+
moduleDirectories: [...baseConfig.moduleDirectories, 'types'],
68
rootDir: path.join(__dirname, '..'),
79
displayName: 'dom',
810
coveragePathIgnorePatterns: [

tests/jest.config.node.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ const baseConfig = require('kcd-scripts/jest')
33

44
module.exports = {
55
...baseConfig,
6+
moduleFileExtensions: [...baseConfig.moduleFileExtensions, 'd.ts'],
7+
moduleDirectories: [...baseConfig.moduleDirectories, 'types'],
68
rootDir: path.join(__dirname, '..'),
79
displayName: 'node',
810
testEnvironment: 'jest-environment-node',

types/config.d.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
export interface Config {
22
testIdAttribute: string
3+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
34
asyncWrapper(cb: (...args: any[]) => any): Promise<any>
5+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
46
eventWrapper(cb: (...args: any[]) => any): void
57
asyncUtilTimeout: number
68
computedStyleSupportsPseudoElements: boolean
79
defaultHidden: boolean
810
showOriginalStackTrace: boolean
911
throwSuggestions: boolean
10-
getElementError: (message: string, container: HTMLElement) => Error
12+
getElementError: (message: string | null, container: Element) => Error
1113
}
1214

1315
export interface ConfigFn {

types/matches.d.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,22 @@
11
import {ARIARole} from 'aria-query'
2+
import {Nullish} from './utils'
23

3-
export type MatcherFunction = (content: string, element: HTMLElement) => boolean
4-
export type Matcher = MatcherFunction | {}
4+
export type MatcherFunction = (
5+
content: string,
6+
element: Nullish<Element>,
7+
) => boolean
8+
export type Matcher = MatcherFunction | RegExp | string
59

610
// Get autocomplete for ARIARole union types, while still supporting another string
711
// Ref: https://github.com/microsoft/TypeScript/issues/29729#issuecomment-505826972
812
export type ByRoleMatcher = ARIARole | MatcherFunction | {}
913

1014
export type NormalizerFn = (text: string) => string
1115

16+
export type NormalizerOptions = DefaultNormalizerOptions & {
17+
normalizer?: NormalizerFn
18+
}
19+
1220
export interface MatcherOptions {
1321
exact?: boolean
1422
/** Use normalizer with getDefaultNormalizer instead */

types/utils.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export type Nullish<T> = T | null | undefined
2+
3+
export type Callback<T> = () => T
4+
5+
export function isNotNull<T>(arg: T): arg is NonNullable<T> {
6+
return arg !== null
7+
}

0 commit comments

Comments
 (0)