Skip to content

Commit aa50516

Browse files
committed
Add a keys function with typing for flow
1 parent cc2fb7e commit aa50516

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

packages/create-instance/create-component-stubs.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// @flow
22

33
import Vue from 'vue'
4-
import { throwError, camelize, capitalize, hyphenate } from '../shared/util'
4+
import { throwError, camelize, capitalize, hyphenate, keys } from '../shared/util'
55
import {
66
componentNeedsCompiling,
77
templateContainsComponent,
@@ -75,7 +75,7 @@ function resolveOptions(component, _Vue) {
7575
return options
7676
}
7777

78-
function getScopedSlotRenderFunctions(ctx: any): Array<String> {
78+
function getScopedSlotRenderFunctions(ctx: any): Array<string> {
7979
// In Vue 2.6+ a new v-slot syntax was introduced
8080
// scopedSlots are now saved in parent._vnode.data.scopedSlots
8181
// We filter out the _normalized and $stable key
@@ -86,7 +86,8 @@ function getScopedSlotRenderFunctions(ctx: any): Array<String> {
8686
ctx.$options.parent._vnode.data &&
8787
ctx.$options.parent._vnode.data.scopedSlots
8888
) {
89-
return Object.keys(ctx.$options.parent._vnode.data.scopedSlots).filter(
89+
const slotKeys: Array<string> = ctx.$options.parent._vnode.data.scopedSlots
90+
return keys(slotKeys).filter(
9091
x => x[0] !== '_' && !x.includes('$')
9192
)
9293
}

packages/shared/util.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ function hasOwnProperty(obj, prop) {
3636
return Object.prototype.hasOwnProperty.call(obj, prop)
3737
}
3838

39+
export function keys<T: string>(obj: any): Array<T> {
40+
return Object.keys(obj)
41+
}
42+
3943
export function resolveComponent(id: string, components: Object) {
4044
if (typeof id !== 'string') {
4145
return

0 commit comments

Comments
 (0)