Issue with Vue Casting Empty Strings to true
for boolean | string
Props
Vue.js currently exhibits behavior where it casts empty strings to true
when handling props of type boolean | string
. This issue is problematic because it contradicts the expected behavior of preserving empty strings, especially when there is a need for special handling of empty strings within components.
Details:
-
Type Definition: Consider a prop defined as
value: boolean | string;
. Vue.js is currently converting empty strings totrue
when passed as props, which may lead to unintended behavior and conflicts with component-specific logic designed to handle empty strings differently. -
Type Order Implications: The order in which the prop types are defined (boolean before string or vice versa) affects the return type, further exacerbating the problem. This inconsistency in return types based on type order adds unnecessary complexity to Vue.js component development and can lead to hard-to-debug issues.
pnpm install
pnpm run dev
pnpm run build
pnpm run lint