-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
Script Setup - Class constructor [class] cannot be invoked without 'new' #6483
Comments
The compiler produces this code: (_ctx.$emit('myclick', new _unref(TestClass)()) which is invalid. This should be fixable with an additional set of paranthesis if we need to unwrap directly after (_ctx.$emit('myclick', new (_unref(TestClass))()) |
I created a PR for the bug |
Guys, any update on this? |
Any update on this issue? Does that mean one should avoid using classes within script/setup? Is there a workaround? |
Is it possible to have a follow up on this issue ? The fact that it impacts only the code pushed in production, and not the code in dev mode is especially hurting :'(. For reference I've been bitten by it both for bindings It is sometimes lighter and more readable to be able to new something directly in the template, but if it is not working in production I would largely prefer to break things in my IDE, rather than having to patch some production code somewhere. |
Fixes an error when adding an item (piece or problem) because of an error when using `new` inside an event handler. See: vuejs/core#6483
Vue version
3.2.37
Link to minimal reproduction
https://sfc.vuejs.org/#eNp9kMtOw0AMRX/FGiGlldrMvgRE1Q0fwHI26cSBlMxDHqcFRfl3nAelAond+F7Psa97tY8xP3eodqpIlprIkJC7+Gh842Ighh4IaxigpuAgk9bsar1g4kNbprSYuWZR7Kjkp5TdG1/oGSo4KRhdbEtGqQCKY8ccPDzZtrHvD0bdoWt4lbnPScg24PHyM2K1Xhs1fQR4xrYNE0PPENELmb3Q1UbNC25dGWWR4CVdP/abxUhG7WBSRk0yjbVRb8wx7bROtR1vckp5oFctr5w6z43DHJPbHilcEpKAjdrcMLSIZ6Qtoa+QkP5j/mr9wx2xg/GDRLk9qeTAj+n0FdZl1zJMDuyr6hCcK301p7LBJ6bOcqDV+hr0mzl8ARwjrgw=
Steps to reproduce
Class constructor [class] cannot be invoked without 'new'
is raisedWhat is expected?
No error should be visible in
<script setup>
as the the equivalent behavior is already working in<script>
What is actually happening?
The code is raising an error
Class constructor [class] cannot be invoked without 'new' is raised
System Info
No response
Any additional comments?
See Discussion: #6480
The text was updated successfully, but these errors were encountered: