You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Comment out the defineEmits line in counter.ce.vue, run vue-tsc again.
Observe that the type error disappears.
Manual setup:
constComp1Vue=defineComponent({props: {a: Number,},emits: ['click'],})constComp=defineCustomElement(Comp1Vue)newComp().a=42// property 'a' is read-only
What is expected?
No type error as props shouldn't be read-only.
What is actually happening?
src/main.ts:13:4 - error TS2540: Cannot assign to 'count' because it is a read-only property.
el.count = 42;
This error only appears if defineEmits is present. It shows up in both vscode and vue-tsc.
System Info
No response
Any additional comments?
This is a variant of #7782, which was fixed by #7937 but only for object-style emit declarations. However, type-only emit declarations in SFCs are always compiled into arrays.
The text was updated successfully, but these errors were encountered:
andylizi
changed the title
defineCustomElement makes props readonly when used with defineEmitsdefineCustomElement props become readonly when component defines array emits
Jul 17, 2024
Vue version
3.4.31
Link to minimal reproduction
https://stackblitz.com/edit/vue-ce-type-repro?file=src%2Fmain.ts
Steps to reproduce
Using the reproduction link:
npm install
to finish.npx vue-tsc
defineEmits
line incounter.ce.vue
, runvue-tsc
again.Manual setup:
What is expected?
No type error as props shouldn't be read-only.
What is actually happening?
This error only appears if
defineEmits
is present. It shows up in both vscode andvue-tsc
.System Info
No response
Any additional comments?
This is a variant of #7782, which was fixed by #7937 but only for object-style emit declarations. However, type-only emit declarations in SFCs are always compiled into arrays.
The text was updated successfully, but these errors were encountered: