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

TS4082: Default export of the module has or is using private name 'Props'. #5129

Closed
WangJincheng4869 opened this issue Jan 17, 2025 · 6 comments
Labels
question Further information is requested

Comments

@WangJincheng4869
Copy link

Vue - Official extension or vue-tsc version

2.2.0

VSCode version

1.96.4

Vue version

3.5.13

TypeScript version

5.7.3

System Info

System:
    OS: Windows 10 10.0.26100
    CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
    Memory: 9.71 GB / 31.56 GB
  Binaries:
    Node: 22.11.0 - D:\Program Files\nodejs\node.EXE
    Yarn: 1.22.21 - D:\Users\jcwang\AppData\Roaming\npm\yarn.CMD
    npm: 10.4.0 - D:\Users\jcwang\AppData\Roaming\npm\npm.CMD
  Browsers:
    Edge: Chromium (127.0.2651.86)
    Internet Explorer: 11.0.26100.1882

package.json dependencies

Steps to reproduce

报错信息如下:

src/module/ai/components/manager/FaqDetail.vue:3090:1 - error TS4082: Default export of the module has or is using private name 'Props'.

3090 export default (await import('vue')).defineComponent({
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3091 setup() {
     ~~~~~~~~~
 ...
3096 __typeRefs: {} as __VLS_TemplateResult['refs'],
     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3097 });
     ~~~


Found 1 error in src/module/ai/components/manager/FaqDetail.vue:3090

这个错误是非常诡异的,我的点仅仅有 1133 行,但是报错却是 3090 行。

What is expected?

出现了和这个诡异的错误

What is actually happening?

出现了此错误,希望找到错误的原因,这种错误也是极难复现,可有本地获取详细日志的方式?我可以协助获取并提交。

Link to minimal reproduction

No response

Any additional comments?

No response

@caiwuu
Copy link

caiwuu commented Jan 17, 2025

2022年的一个issues #1232 现在又出现了,版本2.1.10是正常的

@KazariEX
Copy link
Collaborator

KazariEX commented Jan 17, 2025

这是 TS 的限制,有的版本没问题是因为用了一些特殊处理把不可以被直接导出的私有接口展开成新的类型了。

寻找该组件所引用的 interface Props 并导出它或改成 type 即可。

@KazariEX KazariEX added question Further information is requested and removed pending triage labels Jan 17, 2025
@WangJincheng4869
Copy link
Author

这是 TS 的限制,有的版本没问题是因为用了一些特殊处理把不可以被直接导出的私有接口展开成新的类型了。

寻找该组件所引用的 interface Props 并导出它或改成 type 即可。

1 楼回复的时候我尝试找定义类型和导入类型的了,但是报错这个组件的 props 定义没有导入外部类型,导入类型的地方也带上了 type.

import { ref, reactive, watchEffect, getCurrentInstance, watch } from 'vue';
import { Search, More, UploadFilled } from '@element-plus/icons-vue';
import type { AiFaqContentVO, AiFaqContentListVO } from '../types';
import { useBroadcastChannel, useFileDialog } from '@vueuse/core';
import ImportDialog from '@/module/ai/components/manager/ImportDialog.vue';
import FaqDetailDialog from '@/module/ai/components/manager/FaqDetailDialog.vue';
import { listToTree } from '@/module/stat/utils/stat-table-utils';
import type { DragEvents } from 'element-plus/es/components/tree/src/model/useDragNode';
import type { AllowDropType, NodeDropType } from 'element-plus/es/components/tree/src/tree.type';
import ContextMenu from './ContextMenu.vue';
import type { ContextMenuItem } from './ContextMenu.vue';
import type { FileInfo } from '@/hooks/form/use-upload/types';
import type { UploadFiles, UploadFile } from 'element-plus';
import { PublicResourceType } from '@/hooks/form/use-upload/types';

const { post } = useBroadcastChannel({ name: 'updateFaqPage' });
const showDrawer = ref(false);
const treeRef = ref();
const selectedArr = ref<any>([]);
const selectedIds = ref<any>([]);
const selectedParentIds = ref<any>([0]);
const faqDialogRef = ref();
const extraParams = ref({ typeId: 0, typeIds: [0] });
const multipleSelection = ref<AiFaqContentVO[]>([]);
const searchParams = reactive({
  keyword: '',
});
const props = defineProps<{
  id: string;
  name: string;
}>();

PublicResourceType 是一个枚举

@KazariEX
Copy link
Collaborator

该组件上如果有 ref 节点,这些节点的实例类型也会影响到当前组件。

@WangJincheng4869
Copy link
Author

该组件上如果有 ref 节点,这些节点的实例类型也会影响到当前组件。

您指的是报错的这个组件 FaqDetail.vue 在其他地方用到了,且使用了 ref 属性是吗?

@WangJincheng4869
Copy link
Author

直接全局检索 interface Props 把明明为这个的修改了就可以了。

Image

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

No branches or pull requests

3 participants