Skip to content

Commit a21140a

Browse files
authored
Merge pull request #31 from xhayper/patch-1
type: give out types for boolean attributes
2 parents 8519f1e + 44868db commit a21140a

File tree

4 files changed

+14
-12
lines changed

4 files changed

+14
-12
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"pascalCasedName": "JsonEditorVue",
44
"version": "0.10.2",
55
"private": false,
6-
"packageManager": "pnpm@latest",
6+
"packageManager": "pnpm@7.18.1",
77
"description": "JSON editor & viewer for Vue 2.6 / 2.7 / 3 & Nuxt 2 / 3.",
88
"author": "cloydlau",
99
"license": "MIT",

pnpm-lock.yaml

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Component.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import { globalAttrs, globalProps } from './install'
1818

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

21-
const modelValueProp = isVue3 ? 'modelValue' : 'value'
22-
const updateModelValue = isVue3 ? 'update:modelValue' : 'input'
21+
const modelValueProp: any = isVue3 ? 'modelValue' : 'value'
22+
const updateModelValue: any = isVue3 ? 'update:modelValue' : 'input'
2323
const boolAttrs = [
2424
'mainMenuBar',
2525
'navigationBar',
@@ -28,19 +28,20 @@ const boolAttrs = [
2828
'escapeControlCharacters',
2929
'escapeUnicodeCharacters',
3030
'flattenColumns',
31-
]
31+
] as const
3232

3333
export default defineComponent({
3434
name,
35+
inheritAttrs: true,
3536
props: {
3637
[modelValueProp]: {},
3738
mode: {
3839
type: String as PropType<Mode>,
3940
},
40-
...Object.fromEntries(Array.from(boolAttrs, boolAttr => [boolAttr, {
41-
type: Boolean,
41+
...(Object.fromEntries(boolAttrs.map(boolAttr => [boolAttr, {
42+
type: Boolean as PropType<boolean>,
4243
default: undefined,
43-
}])),
44+
}])) as { [key in typeof boolAttrs[number]]: { type: PropType<boolean>; default: undefined } }),
4445
},
4546
emits: [updateModelValue, 'update:mode'],
4647
setup(props, { attrs, emit, expose }) {

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"resolveJsonModule": true,
1616
"esModuleInterop": true,
1717
"removeComments": false,
18+
"skipLibCheck": true,
1819
"jsx": "preserve",
1920
"lib": ["esnext", "dom"],
2021
"types": ["node"],

0 commit comments

Comments
 (0)