hotwired / stimulus

A modest JavaScript framework for the HTML you already have
https://stimulus.hotwired.dev/
MIT License
12.73k stars 426 forks source link

Value declared with a {type: String} but no default value behave like they have a default value #772

Open Intrepidd opened 6 months ago

Intrepidd commented 6 months ago

Consider the following values :

static values = {
  foo: {type: String},
  bar: String
}

If both values are un-set, the following will happen

this.hasFooValue // true
this.hasBarValue // false

Looks like it comes from here :

https://github.com/hotwired/stimulus/blob/e6f1887c9ac91f3d83d8cde0b80c216d0dc3de6e/src/core/value_properties.ts#L55

https://github.com/hotwired/stimulus/blob/e6f1887c9ac91f3d83d8cde0b80c216d0dc3de6e/src/core/value_properties.ts#L213-L215

This is beyond my knowledge but it looks like there is a mixup about what is passed to parseValueTypeDefault