Skip to content

Commit

Permalink
fix: improve filter typing (#1077)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddyerburgh committed Dec 23, 2018
1 parent 71b698d commit a0528ca
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
16 changes: 11 additions & 5 deletions packages/test-utils/types/index.d.ts
Expand Up @@ -113,11 +113,17 @@ export interface Wrapper<V extends Vue | null> extends BaseWrapper {
}

export interface WrapperArray<V extends Vue> extends BaseWrapper {
readonly length: number
readonly wrappers: Array<Wrapper<V>>

at (index: number): Wrapper<V>
filter (predicate: Function): WrapperArray<Vue>
readonly length: number;
readonly wrappers: Array<Wrapper<V>>;

at(index: number): Wrapper<V>;
filter(
predicate: (
value: Wrapper<V>,
index: number,
array: Wrapper<V>[]
) => any
): WrapperArray<Vue>;
}

interface WrapperOptions {
Expand Down
6 changes: 5 additions & 1 deletion packages/test-utils/types/test/wrapper.ts
Expand Up @@ -79,7 +79,11 @@ wrapper.attributes('foo')
*/
let num: number = array.length
found = array.at(1)
array = array.filter((a: any) => a === true)
array = array.filter((w, i, arr) => {
i + 2
arr.length
return w.is('div')
})

let createdWrapper = createWrapper(new Vue().$mount())
createdWrapper.text()
Expand Down

0 comments on commit a0528ca

Please sign in to comment.