Skip to content

Commit 1a06503

Browse files
committed
fix: properly fix typing
1 parent 505f0d2 commit 1a06503

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/Component.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
unref,
1010
watch,
1111
} from 'vue-demi'
12-
import type { HTMLAttributes, PropType } from 'vue-demi'
12+
import type { PropType } from 'vue-demi'
1313
import { JSONEditor } from 'vanilla-jsoneditor'
1414
import { conclude } from 'vue-global-config'
1515
import { debounce } from 'lodash-es'
@@ -18,10 +18,10 @@ import { globalAttrs, globalProps } from './install'
1818

1919
export type Mode = 'tree' | 'text' | 'table'
2020

21-
type ModalValue = typeof isVue3 extends true ? 'modelValue' : 'value'
21+
type ModalValueProp = typeof isVue3 extends true ? 'modelValue' : 'value'
2222
type UpdateModalValue = typeof isVue3 extends true ? 'update:modelValue' : 'input'
2323

24-
const modelValueProp: ModalValue = (isVue3 ? 'modelValue' : 'value') as any
24+
const modelValueProp: ModalValueProp = (isVue3 ? 'modelValue' : 'value') as any
2525
const updateModelValue: UpdateModalValue = (isVue3 ? 'update:modelValue' : 'input') as any
2626

2727
const boolAttributes = [
@@ -34,23 +34,19 @@ const boolAttributes = [
3434
'flattenColumns',
3535
] as const
3636

37-
type Attributes = ModalValue | UpdateModalValue
38-
type BoolAttributes = {
39-
[K in typeof boolAttributes[number]]: boolean
40-
}
41-
42-
export default defineComponent<HTMLAttributes & { mode: PropType<Mode> } & { [K in Attributes]: any } & BoolAttributes, {}, {}, {}, {}, {}, {}, { 'update:mode': (mode: Mode) => void; 'update:modalValue': (value: unknown) => void; 'input': (value: unknown) => void }>({
37+
export default defineComponent({
4338
name,
39+
inheritAttrs: true,
4440
props: {
4541
[modelValueProp]: {},
4642
mode: {
4743
type: String as PropType<Mode>,
4844
},
49-
...Object.fromEntries(Array.from(boolAttributes, boolAttr => [boolAttr, {
45+
...(Object.fromEntries(Array.from(boolAttributes, boolAttr => [boolAttr, {
5046
type: Boolean,
5147
default: undefined,
52-
}])),
53-
} as any,
48+
}])) as { [key in typeof boolAttributes[number]]: { type: BooleanConstructor; default: undefined } }),
49+
},
5450
emits: [updateModelValue, 'update:mode'],
5551
setup(props, { attrs, emit, expose }) {
5652
const currentInstance = getCurrentInstance()?.proxy

0 commit comments

Comments
 (0)