Skip to content

Commit

Permalink
fix: revert default element typings to HTMLElement
Browse files Browse the repository at this point in the history
The type definitions were updated to allow generic element typing in
#1871

However, this "loosened" the default type from `HTMLElement` to
`Element. This was actually a breaking change.

For example, consumers may have had this test code:

```ts
wrapper.element.click()
```

But `click()` only exists on `HTMLElement`, not on `Element`, so test
compilation fails.

This change moves the default type back to `HTMLElement`. If we want to
loosen this requirement in the future, it should be considered a
breaking change.
  • Loading branch information
alecgibson committed Jul 23, 2021
1 parent d56d945 commit 8de6ebe
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/test-utils/types/index.d.ts
Expand Up @@ -75,15 +75,15 @@ interface BaseWrapper {
selector: Selector | void
}

export interface Wrapper<V extends Vue | null, el extends Element = Element> extends BaseWrapper {
export interface Wrapper<V extends Vue | null, el extends HTMLElement = HTMLElement> extends BaseWrapper {
readonly vm: V
readonly element: el
readonly options: WrapperOptions

get<R extends Vue> (selector: VueClass<R>): Wrapper<R>
get<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
get<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(selector: FunctionalComponentOptions<Props, PropDefs>): Wrapper<Vue>
get<el extends Element>(selector: string): Wrapper<Vue, el>
get<el extends HTMLElement>(selector: string): Wrapper<Vue, el>
get (selector: RefSelector): Wrapper<Vue>
get (selector: NameSelector): Wrapper<Vue>

Expand All @@ -96,7 +96,7 @@ export interface Wrapper<V extends Vue | null, el extends Element = Element> ext
find<R extends Vue> (selector: VueClass<R>): Wrapper<R>
find<R extends Vue> (selector: ComponentOptions<R>): Wrapper<R>
find<Props = DefaultProps, PropDefs = PropsDefinition<Props>>(selector: FunctionalComponentOptions<Props, PropDefs>): Wrapper<Vue>
find<el extends Element>(selector: string): Wrapper<Vue, el>
find<el extends HTMLElement>(selector: string): Wrapper<Vue, el>
find (selector: RefSelector): Wrapper<Vue>
find (selector: NameSelector): Wrapper<Vue>

Expand Down

0 comments on commit 8de6ebe

Please sign in to comment.