-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Empty type name in warning when expected prop type is a custom class #7197
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
Comments
This happens when TS is not used and this method of defining props with custom classes is even referenced in Vue's guide to prop validation: https://vuejs.org/guide/components/props.html#runtime-type-checks |
Already realized my mistake, sorry about that. |
This function returns an empty string for custom classes because core/packages/runtime-core/src/componentProps.ts Lines 559 to 562 in f3e4f03
|
Vue version
3.2.45
Link to minimal reproduction
https://sfc.vuejs.org/#__DEV____SSR__eNp9UstO6zAQ/ZW53rRI1Na9FzZRi0CwYIPEoktvQjJtA/FDHqcFRfl3Jm5SoEA3iWbO8Zwzj1bceC+3DYpMzKkIlY9AGBt/pW1lvAsRWgi4gg5WwRmYMHVygB7ebuucaICkGmL5TB+cW2f8gdAHvRrD2hbOUoTKbvO6Kh+D88s3j7AAizu4yyNOz0bOT4xBazpZbiqCtUOCHdb1hB/N1b4T7oGDiMbXXI4jgPnmb/oD3DPZwc6FuvyTEDVAKUius4gUF1ocWdRCMXGuDoXFudg3OzO55+ad5Wm2qdYAkBYZpEyf4wH0sRabGD1lSjXWv6xl4Yy6ZkyFxsbK4Kx05vq//CcvLlVZUfycl0hm9hTcjjCwohbnn4orTm4xzALaEgOGk2JH3C+CR9g30V6z07bjAYyb/f2OTh7Lfs+eJ0y83xJXlcV+3jRNU+sXkY0VWPDUknVcMhvadl9O9m+loTV0bPXr1j4ssG18TTZZO2/qCEUyO5pOLpLJ0BTRhSkXPBs3GvkCk8IC+HsYSvcOOMAsfg==
Steps to reproduce
Juggle between passing the
invalidPropType
andvalidPropType
to the component and observe the warning messageWhat is expected?
The warning message should contain the expected class' name
What is actually happening?
Warning message contains an empty string
System Info
No response
Any additional comments?
The issue comes from the
getType
function (core/packages/runtime-core/src/componentProps.ts
Line 560 in 54b6ba3
toString()
result for afunction
keyword. This fails for classes since they return aclass [NAME] {}
when stringified. Couldn't we just usector.name
here? It returnsObject
when passed an object,Array
when passed an array etc, I don't know if it's widely supported thoughThe text was updated successfully, but these errors were encountered: