Description
Vue version
^3.5.16
Link to minimal reproduction
Steps to reproduce
When using lang=ts
with defineProps<T>()
production builds of the component when defined as a custom element defineCustomElement
don't coerce string prop attributes to numbers. This works perfectly fine in dev mode.
When referring to the reproduction link, please select the Comp.vue
tab, then toggle between DEV and PROD you will see the behavior of the rendered value swapping between 6.03
and 5.50.53
. This is stable for some reason when viewing from the App.vue
container.
What is expected?
When building vue code for production, defineCustomElement
should coerce string props to number props if a valid number string is provided i.e.
<ce-comps project-id="5" />
What is actually happening?
Provided <ce-comps project-id="5" />
const props = defineProps<{projectId: number}>();
props.projectId === 5 // false in production
props.projectId === "5" // true in production
System Info
System:
OS: Windows 11 10.0.26100
CPU: (20) x64 13th Gen Intel(R) Core(TM) i7-13700H
Memory: 31.54 GB / 63.68 GB
Binaries:
Node: 22.13.1 - D:\Program Files\nodejs\node.EXE
Yarn: 4.4.0 - D:\Program Files\nodejs\yarn.CMD
npm: 10.9.2 - D:\Program Files\nodejs\npm.CMD
bun: 1.2.9 - ~\.bun\bin\bun.EXE
Browsers:
Edge: Chromium (138.0.3351.55)
Internet Explorer: 11.0.26100.1882
npmPackages:
vue: ^3.5.16 => 3.5.16
Any additional comments?
When reverting to this syntax, coercion works as documented here
const props = defineProps({
projectId: {
type: Number,
default: -1,
},
});
props.projectId === 5 // true in production
props.projectId === "5" // false in production
Related issues: #8987