Skip to content

Commit 4b4a9c3

Browse files
committed
feat: add type for @opentiny/tiny-engine-common
1 parent 552c41b commit 4b4a9c3

9 files changed

Lines changed: 40 additions & 6 deletions

File tree

packages/common/component/BindI18n.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656

5757
<script lang="ts">
5858
import { reactive, ref, watchEffect } from 'vue'
59+
import type { Component } from 'vue'
5960
import { useLayout, useTranslate } from '@opentiny/tiny-engine-meta-register'
6061
import { PROP_DATA_TYPE } from '../js/constants'
6162
import { utils } from '@opentiny/tiny-engine-utils'
@@ -65,7 +66,7 @@ export default {
6566
components: {
6667
TinySelect: Select,
6768
TinyOption: Option,
68-
TinyButton: Button,
69+
TinyButton: Button as Component,
6970
TinyInput: Input
7071
},
7172
inheritAttrs: false,

packages/common/component/LifeCycles.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,15 @@ import { initCompletion } from '../js/completion'
9797
import { initLinter, lint } from '../js/linter'
9898
import { SvgButton } from '../index'
9999
import { constants } from '@opentiny/tiny-engine-utils'
100+
100101
const { OPEN_DELAY } = constants
101102
102103
export default {
103104
components: {
104105
TinyPopover: Popover as Component,
105106
TinyDialogBox: DialogBox,
106107
TinySearch: Search,
107-
TinyButton: Button,
108+
TinyButton: Button as Component,
108109
MonacoEditor: VueMonaco,
109110
SvgButton,
110111
MetaListItems,

packages/common/component/MetaCodeEditor.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676

7777
<script lang="ts">
7878
import { computed, nextTick, reactive, ref, watchEffect } from 'vue'
79+
import type { Component } from 'vue'
7980
import { Button, DialogBox, Split } from '@opentiny/vue'
8081
import VueMonaco from './VueMonaco.vue'
8182
import { formatString } from '../js/ast'
@@ -85,7 +86,7 @@ export default {
8586
components: {
8687
TinySplit: Split,
8788
MonacoEditor: VueMonaco,
88-
TinyButton: Button,
89+
TinyButton: Button as Component,
8990
TinyDialogBox: DialogBox
9091
},
9192
props: {

packages/common/component/MetaForm.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616

1717
<script lang="ts">
1818
import { reactive } from 'vue'
19+
import type { Component } from 'vue'
1920
import { Form, FormItem, Input, Button } from '@opentiny/vue'
2021
2122
export default {
2223
components: {
2324
TinyForm: Form,
2425
TinyFormItem: FormItem,
2526
TinyInput: Input,
26-
TinyButton: Button
27+
TinyButton: Button as Component
2728
},
2829
props: {
2930
option: {

packages/common/component/MetaModalItem.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
</template>
2727

2828
<script lang="ts">
29+
import type { Component } from 'vue'
2930
import { Button } from '@opentiny/vue'
3031
import { iconClose } from '@opentiny/vue-icon'
3132
import { reactive, computed } from 'vue'
@@ -34,7 +35,7 @@ import MetaChildItem from './MetaChildItem.vue'
3435
export default {
3536
components: {
3637
MetaChildItem,
37-
TinyButton: Button,
38+
TinyButton: Button as Component,
3839
IconClose: iconClose()
3940
},
4041
props: {

packages/common/component/MetaPopover.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default {
2121
components: {
2222
MetaChildItem,
2323
TinyPopover: Popover as Component,
24-
TinyButton: Button
24+
TinyButton: Button as Component
2525
},
2626
inheritAttrs: false,
2727
props: {

packages/common/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"main": "dist/index.js",
1111
"module": "dist/index.js",
12+
"types": "dist/index.d.ts",
1213
"type": "module",
1314
"exports": {
1415
".": "./dist/index.js",
@@ -56,6 +57,7 @@
5657
"@vitejs/plugin-vue-jsx": "^4.0.1",
5758
"glob": "^10.3.4",
5859
"vite": "^5.4.2",
60+
"vite-plugin-dts": "^4.5.4",
5961
"vite-plugin-static-copy": "^1.0.6"
6062
},
6163
"peerDependencies": {

packages/common/tsconfig.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"compilerOptions": {
4+
"composite": true,
5+
"tsBuildInfoFile": "./node_modules/.tmp/tsconfig.app.tsbuildinfo",
6+
"module": "ESNext",
7+
8+
/* Bundler mode */
9+
"moduleResolution": "Bundler",
10+
"allowJs": true,
11+
"allowImportingTsExtensions": true,
12+
"isolatedModules": true,
13+
"moduleDetection": "force",
14+
"emitDeclarationOnly": true,
15+
"jsx": "preserve",
16+
"useDefineForClassFields": true
17+
},
18+
"include": ["index.ts", "js/**/*.js", "component/**/*", "composable/**/*"]
19+
}

packages/common/vite.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { glob } from 'glob'
1818
import { fileURLToPath } from 'node:url'
1919
import generateComments from '@opentiny/tiny-engine-vite-plugin-meta-comments'
2020
import { viteStaticCopy } from 'vite-plugin-static-copy'
21+
import dts from 'vite-plugin-dts'
2122

2223
const jsEntries = glob.sync('./js/**/*.js').map((file) => {
2324
return [file.slice(0, file.length - path.extname(file).length), fileURLToPath(new URL(file, import.meta.url))]
@@ -37,6 +38,13 @@ export default defineConfig({
3738
dest: '.'
3839
}
3940
]
41+
}),
42+
dts({
43+
tsconfigPath: path.resolve(__dirname, './tsconfig.json'),
44+
rollupTypes: true,
45+
outDir: path.resolve(__dirname, './dist'),
46+
entryRoot: path.resolve(__dirname, './')
47+
// include: ['index.ts', 'js/**/*.js', 'component/**/*', 'composable/**/*']
4048
})
4149
],
4250
publicDir: false,

0 commit comments

Comments
 (0)