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: improve filter typing #1077

Merged
merged 1 commit into from Dec 23, 2018
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
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