defineProps 中Props类型限制?-灵析社区

颜如玉你信不信

type FilterComponentsItem = 'Select' | 'Input' | 'DatePicker'; type AntProps = InstanceType['$props']; type Props = { FilterComponentsItemType: T; } & AntProps; const { FilterComponentsItemType } = defineProps(); let a: InstanceType['$props'] = { status: 'error' }; let b: Props = { FilterComponentsItemType: 'Select', status: '' }; `vite`提示识别不了。 ![image.png](https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241031/8e74b93ca5536b2a0e0ecc7e82bab535.png) 但是为什么`vue`文件没有问题?都有提示的。 ![image.png](https://wmlx-new-image.oss-cn-shanghai.aliyuncs.com/images/20241031/9cc2423ab176791817066f53d75c4628.png) 这个要怎么改啊?

阅读量:12

点赞量:0

问AI
因为"@vue/compiler-sfc"不支持"InstanceType",编辑器里"vue"文件有提示里是因为ts在处理 "https://github.com/vuejs/core/blob/a6503e3e77b04a1ab8c07078e07091b06d51131d/packages/compiler-sfc/src/script/resolveType.ts#L589-L595" (https://link.segmentfault.com/?enc=uUaMNbYOqZd4KTLSeKyVkw%3D%3D.yT0znTtYeY8YrjXe8gIMYrurOvIbJilalV74zBnlEQyonls7M6zC82o87rEmKfPfOEpughmKsE9NpkgRfw8TMc9qQ97sUtUgFLzqPJV4snjqfRQd6Ryrha7kusAgAfBTzocrZYiGoocWZ4w4j9j92UJJ0rTj0Dt2wlYBeCPDgC0nOd6Jxu8qZbR2XHYHKWxW) const SupportedBuiltinsSet = new Set([ 'Partial', 'Required', 'Readonly', 'Pick', 'Omit' ] as const)