Skip to content

Commit 0cffc2a

Browse files
committed
fix: build typing TS2742
1 parent e8bbe58 commit 0cffc2a

File tree

9 files changed

+82
-37
lines changed

9 files changed

+82
-37
lines changed

Diff for: .eslintignore

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
node_modules/
2+
**/dist/**
3+
**/*.spec.*
4+
*.html

Diff for: package.json

+6-8
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,22 @@
3333
"devDependencies": {
3434
"@rushstack/eslint-patch": "^1.1.0",
3535
"@types/jsdom": "^16.2.14",
36-
"@types/node": "^16.11.22",
37-
"@vitejs/plugin-vue": "^2.1.0",
38-
"@vitejs/plugin-vue-jsx": "^1.3.3",
36+
"@types/node": "^16.11.24",
37+
"@vitejs/plugin-vue": "^2.2.0",
38+
"@vitejs/plugin-vue-jsx": "^1.3.7",
3939
"@vue/eslint-config-prettier": "^7.0.0",
4040
"@vue/eslint-config-typescript": "^10.0.0",
4141
"@vue/test-utils": "^2.0.0-rc.18",
4242
"@vue/tsconfig": "^0.1.3",
43-
"eslint": "^8.5.0",
44-
"eslint-plugin-vue": "^8.2.0",
43+
"eslint": "^8.9.0",
44+
"eslint-plugin-vue": "^8.4.1",
4545
"jsdom": "^19.0.0",
4646
"prettier": "^2.5.1",
4747
"typescript": "~4.5.5",
4848
"vite": "^2.8.6",
49-
"vitest": "^0.5.0",
49+
"vitest": "^0.5.8",
5050
"vue-tsc": "^0.31.4"
5151
},
52-
"dependencies": {
53-
},
5452
"lint-staged": {
5553
"*.{js,ts,vue,json}": [
5654
"pnpm lint"

Diff for: packages/pro-layout/src/components/PageContainer/index.tsx

+16-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export const pageHeaderTabConfig = {
4747
/**
4848
* @name 当前选中 tab 的 key
4949
*/
50-
tabActiveKey: PropTypes.string,
50+
tabActiveKey: String, //PropTypes.string,
5151
/**
5252
* @name tab 上多余的区域
5353
*/
@@ -59,22 +59,25 @@ export const pageHeaderTabConfig = {
5959
* @name tabs 的其他配置
6060
*/
6161
tabProps: {
62-
type: Object as PropType<TabsProps>,
62+
type: Object, //as PropType<TabsProps>,
6363
default: () => undefined,
6464
},
6565
/**
6666
* @name 固定 PageHeader 到页面顶部
6767
*/
68-
fixedHeader: PropTypes.looseBool,
68+
fixedHeader: Boolean,//PropTypes.looseBool,
6969
// events
70-
onTabChange: PropTypes.func,
70+
onTabChange: Function,//PropTypes.func,
7171
}
7272
export type PageHeaderTabConfig = Partial<ExtractPropTypes<typeof pageHeaderTabConfig>>
7373

7474
export const pageContainerProps = {
7575
...pageHeaderTabConfig,
7676
...pageHeaderProps,
77-
prefixCls: PropTypes.string.def('ant-pro'),
77+
prefixCls: {
78+
type: String,
79+
default: 'ant-pro',
80+
},//PropTypes.string.def('ant-pro'),
7881
title: {
7982
type: [Object, String, Boolean, Function] as PropType<DefaultPropRender>,
8083
default: () => null,
@@ -105,8 +108,14 @@ export const pageContainerProps = {
105108
affixProps: {
106109
type: [Object, Function] as PropType<AffixProps>,
107110
},
108-
ghost: PropTypes.looseBool,
109-
loading: PropTypes.looseBool,
111+
ghost: {
112+
type: Boolean,
113+
default: () => undefined,
114+
},//PropTypes.looseBool,
115+
loading: {
116+
type: Boolean,
117+
default: () => undefined,
118+
}, //PropTypes.looseBool,
110119
}
111120

112121
export type PageContainerProps = Partial<ExtractPropTypes<typeof pageContainerProps>>

Diff for: packages/pro-layout/tsconfig.app.json

-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44
"exclude": ["src/**/__tests__/*", "node_modules"],
55
"compilerOptions": {
66
"composite": true,
7-
"baseUrl": ".",
87
"paths": {
98
"@/*": ["./src/*"],
109
"@ant-design-vue/pro-layout":["./src/index.ts"]
11-
1210
}
1311
}
1412
}

Diff for: packages/pro-layout/tsconfig.esm.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
3+
"exclude": ["src/**/__tests__/*"],
4+
"compilerOptions": {
5+
"target": "esnext",
6+
"module": "esnext",
7+
"moduleResolution": "node",
8+
"strict": true,
9+
"jsx": "preserve",
10+
"sourceMap": false,
11+
"resolveJsonModule": true,
12+
"esModuleInterop": true,
13+
"skipLibCheck": true,
14+
"lib": ["esnext", "dom"],
15+
"types": ["vite/client", "node"],
16+
"outDir": "dist",
17+
"declaration": true,
18+
"forceConsistentCasingInFileNames": true,
19+
"baseUrl": ".",
20+
"paths": {
21+
// FIXME: this fixed vue-types ERROR. TS2742 cannot be named without a reference to `xxx`
22+
"vue-types": ["../../node_modules/vue-types"]
23+
}
24+
}
25+
}

Diff for: packages/pro-layout/tsconfig.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
{
2-
"include": ["src/**/*.ts", "src/**/*.d.ts"],
32
"compilerOptions": {
4-
"declaration": true,
5-
"declarationDir": "./dist"
3+
"baseUrl": ".",
4+
"preserveSymlinks": true
65
},
76
"files": [],
87
"references": [

Diff for: packages/pro-layout/vite.config.ts

+17-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,15 @@ export default defineConfig({
3636
name: 'ProLayout',
3737
},
3838
rollupOptions: {
39-
external: ['vue', 'vue-router', '@ant-design/icons-vue', '@ant-design/icons-svg', 'ant-design-vue', 'moment'],
39+
external: [
40+
'vue',
41+
'vue-router',
42+
'@ant-design/icons-vue',
43+
'@ant-design/icons-svg',
44+
'ant-design-vue',
45+
'moment',
46+
'vue-types',
47+
],
4048
output: {
4149
exports: 'named',
4250
// Provide global variables to use in the UMD build
@@ -47,17 +55,20 @@ export default defineConfig({
4755
'ant-design-vue': 'antd',
4856
'@ant-design/icons-vue': 'iconsVue',
4957
'@ant-design/icons-svg': 'iconsSvg',
58+
'vue-types': 'vueTypes',
5059
moment: 'moment',
5160
},
5261
},
5362
plugins: [
5463
typescript({
64+
tsconfig: './tsconfig.esm.json',
5565
target: 'es2020',
56-
rootDir: './src',
57-
declaration: true,
58-
declarationDir: './dist',
59-
exclude: 'node_modules/**',
60-
allowSyntheticDefaultImports: true,
66+
emitDeclarationOnly: true,
67+
// outDir: 'dist',
68+
// declaration: true,
69+
// declarationDir: '.',
70+
// exclude: 'node_modules/**',
71+
// allowSyntheticDefaultImports: true,
6172
}),
6273
],
6374
},

Diff for: packages/shared/plugin-less-copy/src/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@ function createPlugin(): Plugin {
2222

2323
generateBundle() {
2424
maps.forEach((code, file) => {
25+
const filename = file.replace(srcDir, '').substring(1)
2526
this.emitFile({
2627
type: 'asset',
27-
fileName: file.replace(srcDir, '').substring(1),
28+
fileName: filename,
2829
source: code,
2930
})
3031
})

Diff for: pnpm-lock.yaml

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)