Subscribe on changes!

Vue 3.3.3, defineProps/ defineEmits could not resolve default exported types

avatar
May 18th 2023

Vue version

3.3.3

Link to minimal reproduction

https://github.com/tragid/vue-default-export-error

Steps to reproduce

  1. Create props interface file: TestComponentProps.ts
  2. Create default export from file
export default interface TestComponentProps {
  msg: string;
}
  1. import type within component TestComponent.vue
import type TestComponentProps from './TestComponentProps';

const props = defineProps<TestComponentProps>();
  1. Vue throws error on startup. [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type

What is expected?

Vue can resolve defaultly imported types

What is actually happening?

Vue throws error on startup. [@vue/compiler-sfc] Unresolvable type reference or unsupported built-in utility type

System Info

No response

Any additional comments?

Everything works, if I create export from file with no default provided

export interface TestComponentProps {
  msg: string;
}
import type { TestComponentProps } from './TestComponentProps';

const props = defineProps<TestComponentProps>();
avatar
May 18th 2023

@yyx990803 Hi! Fix helped to get rid of compile time errors. Now having runtime errors, when importing default Props and default Emits in a row.

runtime-core.esm-bundler.js:41 [Vue warn]: Property "tag" was accessed during render but is not defined on instance. 
  at <TestComponent msg="Hello World!" tag="span" onClick=fn<onClick> > 
  at <App>

I have created a branch with 3.3.4 version with minimal reproduction: https://github.com/tragid/vue-default-export-error/tree/vue-3.3.4

avatar
May 18th 2023

Please open a separate issue so that it can be tracked as a different bug.