Skip to content

Commit

Permalink
fix: build typing TS2742
Browse files Browse the repository at this point in the history
  • Loading branch information
sendya committed Mar 12, 2022
1 parent e8bbe58 commit 0cffc2a
Show file tree
Hide file tree
Showing 9 changed files with 82 additions and 37 deletions.
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
**/dist/**
**/*.spec.*
*.html
14 changes: 6 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,22 @@
"devDependencies": {
"@rushstack/eslint-patch": "^1.1.0",
"@types/jsdom": "^16.2.14",
"@types/node": "^16.11.22",
"@vitejs/plugin-vue": "^2.1.0",
"@vitejs/plugin-vue-jsx": "^1.3.3",
"@types/node": "^16.11.24",
"@vitejs/plugin-vue": "^2.2.0",
"@vitejs/plugin-vue-jsx": "^1.3.7",
"@vue/eslint-config-prettier": "^7.0.0",
"@vue/eslint-config-typescript": "^10.0.0",
"@vue/test-utils": "^2.0.0-rc.18",
"@vue/tsconfig": "^0.1.3",
"eslint": "^8.5.0",
"eslint-plugin-vue": "^8.2.0",
"eslint": "^8.9.0",
"eslint-plugin-vue": "^8.4.1",
"jsdom": "^19.0.0",
"prettier": "^2.5.1",
"typescript": "~4.5.5",
"vite": "^2.8.6",
"vitest": "^0.5.0",
"vitest": "^0.5.8",
"vue-tsc": "^0.31.4"
},
"dependencies": {
},
"lint-staged": {
"*.{js,ts,vue,json}": [
"pnpm lint"
Expand Down
23 changes: 16 additions & 7 deletions packages/pro-layout/src/components/PageContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const pageHeaderTabConfig = {
/**
* @name 当前选中 tab 的 key
*/
tabActiveKey: PropTypes.string,
tabActiveKey: String, //PropTypes.string,
/**
* @name tab 上多余的区域
*/
Expand All @@ -59,22 +59,25 @@ export const pageHeaderTabConfig = {
* @name tabs 的其他配置
*/
tabProps: {
type: Object as PropType<TabsProps>,
type: Object, //as PropType<TabsProps>,
default: () => undefined,
},
/**
* @name 固定 PageHeader 到页面顶部
*/
fixedHeader: PropTypes.looseBool,
fixedHeader: Boolean,//PropTypes.looseBool,
// events
onTabChange: PropTypes.func,
onTabChange: Function,//PropTypes.func,
}
export type PageHeaderTabConfig = Partial<ExtractPropTypes<typeof pageHeaderTabConfig>>

export const pageContainerProps = {
...pageHeaderTabConfig,
...pageHeaderProps,
prefixCls: PropTypes.string.def('ant-pro'),
prefixCls: {
type: String,
default: 'ant-pro',
},//PropTypes.string.def('ant-pro'),
title: {
type: [Object, String, Boolean, Function] as PropType<DefaultPropRender>,
default: () => null,
Expand Down Expand Up @@ -105,8 +108,14 @@ export const pageContainerProps = {
affixProps: {
type: [Object, Function] as PropType<AffixProps>,
},
ghost: PropTypes.looseBool,
loading: PropTypes.looseBool,
ghost: {
type: Boolean,
default: () => undefined,
},//PropTypes.looseBool,
loading: {
type: Boolean,
default: () => undefined,
}, //PropTypes.looseBool,
}

export type PageContainerProps = Partial<ExtractPropTypes<typeof pageContainerProps>>
Expand Down
2 changes: 0 additions & 2 deletions packages/pro-layout/tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
"exclude": ["src/**/__tests__/*", "node_modules"],
"compilerOptions": {
"composite": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"],
"@ant-design-vue/pro-layout":["./src/index.ts"]

}
}
}
25 changes: 25 additions & 0 deletions packages/pro-layout/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"include": ["env.d.ts", "src/**/*", "src/**/*.vue"],
"exclude": ["src/**/__tests__/*"],
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"strict": true,
"jsx": "preserve",
"sourceMap": false,
"resolveJsonModule": true,
"esModuleInterop": true,
"skipLibCheck": true,
"lib": ["esnext", "dom"],
"types": ["vite/client", "node"],
"outDir": "dist",
"declaration": true,
"forceConsistentCasingInFileNames": true,
"baseUrl": ".",
"paths": {
// FIXME: this fixed vue-types ERROR. TS2742 cannot be named without a reference to `xxx`
"vue-types": ["../../node_modules/vue-types"]
}
}
}
5 changes: 2 additions & 3 deletions packages/pro-layout/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
{
"include": ["src/**/*.ts", "src/**/*.d.ts"],
"compilerOptions": {
"declaration": true,
"declarationDir": "./dist"
"baseUrl": ".",
"preserveSymlinks": true
},
"files": [],
"references": [
Expand Down
23 changes: 17 additions & 6 deletions packages/pro-layout/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ export default defineConfig({
name: 'ProLayout',
},
rollupOptions: {
external: ['vue', 'vue-router', '@ant-design/icons-vue', '@ant-design/icons-svg', 'ant-design-vue', 'moment'],
external: [
'vue',
'vue-router',
'@ant-design/icons-vue',
'@ant-design/icons-svg',
'ant-design-vue',
'moment',
'vue-types',
],
output: {
exports: 'named',
// Provide global variables to use in the UMD build
Expand All @@ -47,17 +55,20 @@ export default defineConfig({
'ant-design-vue': 'antd',
'@ant-design/icons-vue': 'iconsVue',
'@ant-design/icons-svg': 'iconsSvg',
'vue-types': 'vueTypes',
moment: 'moment',
},
},
plugins: [
typescript({
tsconfig: './tsconfig.esm.json',
target: 'es2020',
rootDir: './src',
declaration: true,
declarationDir: './dist',
exclude: 'node_modules/**',
allowSyntheticDefaultImports: true,
emitDeclarationOnly: true,
// outDir: 'dist',
// declaration: true,
// declarationDir: '.',
// exclude: 'node_modules/**',
// allowSyntheticDefaultImports: true,
}),
],
},
Expand Down
3 changes: 2 additions & 1 deletion packages/shared/plugin-less-copy/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ function createPlugin(): Plugin {

generateBundle() {
maps.forEach((code, file) => {
const filename = file.replace(srcDir, '').substring(1)
this.emitFile({
type: 'asset',
fileName: file.replace(srcDir, '').substring(1),
fileName: filename,
source: code,
})
})
Expand Down
20 changes: 10 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0cffc2a

Please sign in to comment.