Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

antd4.x vite vue3.3.6 ts 在script中import引入Modal报错,运行不了,800多error(Type 'T' does not satisfy the constraint 'Record<string, any>'.) #7210

Closed
1 task
lym11 opened this issue Dec 20, 2023 · 4 comments
Labels

Comments

@lym11
Copy link

lym11 commented Dec 20, 2023

  • I have searched the issues of this repository and believe that this is not a duplicate.

Version

4.0.8

Environment

vue3.3.6

Reproduction link

https://antdv.com/docs/vue/introduce-cn

Steps to reproduce

<script setup lang="ts"> import { ref, computed, createVNode } from 'vue'; import { ExclamationCircleOutlined } from '@ant-design/icons-vue'; import { Modal } from 'ant-design-vue'; const showConfirm = () => { Modal.confirm({ title: 'Do you Want to delete these items?', icon: createVNode(ExclamationCircleOutlined), content: createVNode('div', { style: 'color:red;' }, 'Some descriptions'), onOk() { console.log('OK'); }, onCancel() { console.log('Cancel'); }, class: 'test', }); }; </script>

What is expected?

希望代码运行成功不报错

What is actually happening?

代码启动报错(tsc)
Property 'zoom' of type 'Zoom | readonly NonNullable<Zoom | undefined>[] | ((string & {}) | Globals | "normal" | "reset")[] | { value: Zoom | readonly NonNullable<Zoom | undefined>[] | ((string & {}) | ... 2 more ... | "reset")[] | undefined; skip_check: boolean; multi_value?: boolean | undefined; } | undefined' is not assignable to 'string' index type 'CSSInterpolation'.
FILE /xxx/node_modules/ant-design-vue/es/_util/cssinjs/hooks/useStyleRegister/index.d.ts:28:18

26 | export type CSSInterpolation = InterpolationPrimitive | ArrayCSSInterpolation | Keyframes;
27 | export type CSSOthersObject = Record<string, CSSInterpolation>;

28 | export interface CSSObject extends CSSPropertiesWithMultiValues, CSSPseudos, CSSOthersObject {
| ^^^^^^^^^
29 | }
30 | export declare function normalizeStyle(styleStr: string): string;
31 | export interface ParseConfig {

ERROR(vue-tsc) Type 'T' does not satisfy the constraint 'Record<string, any>'.
FILE /Users/liaoym/Desktop/work/316-frontend-phone/node_modules/ant-design-vue/es/_util/type.d.ts:60:44

58 | default: T;
59 | };

60 | export type CustomSlotsType = SlotsType;
| ^
61 | export type AnyObject = Record<PropertyKey, any>;
62 | export {};
63 |

[vue-tsc] Found 826 errors. Watching for file changes.


package.json文件
{
"devDependencies": {
"@types/crypto-js": "^4.1.3",
"@types/js-cookie": "^3.0.5",
"@types/lodash": "^4.14.201",
"@types/node": "^20.8.7",
"@types/qs": "^6.9.10",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"@vant/auto-import-resolver": "^1.0.2",
"@vitejs/plugin-vue": "^4.4.0",
"@vitejs/plugin-vue-jsx": "^3.0.2",
"@vue/tsconfig": "^0.4.0",
"eslint": "^8.52.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
"eslint-plugin-vue": "^9.17.0",
"less": "^4.2.0",
"plop": "^4.0.0",
"postcss": "^8.4.31",
"postcss-preset-env": "^9.2.0",
"postcss-px-to-viewport": "^1.1.1",
"postcss-pxtorem": "^6.0.0",
"prettier": "^3.1.1",
"rollup-plugin-visualizer": "^5.10.0",
"sass": "^1.69.4",
"stylelint": "^15.11.0",
"ts-node": "^10.9.1",
"typescript": "^5.2.2",
"unplugin-vue-components": "^0.25.2",
"vite": "^4.5.0",
"vite-plugin-checker": "^0.6.2",
"vite-plugin-eslint": "^1.8.1",
"vite-plugin-svg-icons": "^2.0.1",
"vite-plugin-vue-setup-extend": "^0.4.0",
"vue-tsc": "^1.8.19"
},
"dependencies": {
"@imengyu/vue3-context-menu": "^1.3.5",
"ant-design-vue": "4.x",
"axios": "^1.5.1",
"crypto-js": "^4.1.1",
"echarts": "^5.4.3",
"js-cookie": "^3.0.5",
"jsencrypt": "^3.3.2",
"lodash-es": "^4.17.21",
"num-tofixed": "^1.0.3",
"pinia": "^2.1.7",
"qs": "^6.11.2",
"tailwindcss": "^3.3.5",
"vant": "^4.7.2",
"vue": "^3.3.6",
"vue-router": "^4.2.5",
"vuedraggable": "^4.1.0"
}
}

@kovsu
Copy link
Member

kovsu commented Dec 21, 2023

复现不了你说的问题。
image

@kovsu
Copy link
Member

kovsu commented Dec 21, 2023

但是你这个报错我见到过,#7201 在这里应该是修复了
引发报错的原因是 https://github.com/vueComponent/ant-design-vue/pull/7201/files#diff-84ad232e8a8cfbfa3365d26fb74e0e8ce9568e306053bf338918e5db27cacc31R88 这行代码

@lym11
Copy link
Author

lym11 commented Dec 21, 2023

但是你这个报错我见到过,#7201 在这里应该是修复了 引发报错的原因是 https://github.com/vueComponent/ant-design-vue/pull/7201/files#diff-84ad232e8a8cfbfa3365d26fb74e0e8ce9568e306053bf338918e5db27cacc31R88 这行代码

我找别人帮忙,他在tsconfig.json里加了这个("skipLibCheck": true)就可以了。你复现不了是不是你tsconfig.json也有这个,还是说你的page.json的版本跟我的不一样?(我的问题里有贴我当前的devDependencies和dependencies)

Copy link

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants