Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: typescript definitions for suggestions #630

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/suggestions.js
Expand Up @@ -72,7 +72,7 @@ function canSuggest(currentMethod, requestedMethod, data) {
return data && (!requestedMethod || requestedMethod === currentMethod)
}

export function getSuggestedQuery(element, variant, method) {
export function getSuggestedQuery(element, variant = 'get', method) {
// don't create suggestions for script and style elements
if (element.matches(DEFAULT_IGNORE_TAGS)) {
return undefined
Expand Down
32 changes: 31 additions & 1 deletion types/suggestions.d.ts
Expand Up @@ -3,4 +3,34 @@ export interface Suggestion {
toString(): string
}

export function getSuggestedQuery(element: HTMLElement): Suggestion | undefined
export type Variant =
| 'get'
| 'getAll'
| 'query'
| 'queryAll'
| 'find'
| 'findAll'

export type Method =
| 'Role'
| 'role'
| 'LabelText'
| 'labeltext'
| 'PlaceholderText'
| 'placeholdertext'
| 'Text'
| 'text'
| 'DisplayValue'
| 'displayvalue'
| 'AltText'
| 'alttext'
| 'Title'
| 'title'
| 'TestId'
| 'testtd'

export function getSuggestedQuery(
element: HTMLElement,
variant?: Variant,
method?: Method,
): Suggestion | undefined