feat: throw TypeError when setting different type
This commit is contained in:
parent
7500f0c3fe
commit
98c89624f9
2 changed files with 3 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "web-component-base",
|
||||
"version": "2.0.0-beta.8",
|
||||
"version": "2.0.0-beta.9",
|
||||
"description": "A zero-dependency, ~600 Bytes (minified & gzipped), JS base class for creating reactive custom elements easily",
|
||||
"type": "module",
|
||||
"exports": {
|
||||
|
|
|
@ -134,6 +134,8 @@ export class WebComponent extends HTMLElement {
|
|||
effectsMap[prop] = [];
|
||||
}
|
||||
effectsMap[prop].push(value.callback);
|
||||
} else if (typeof oldValue !== typeof value) {
|
||||
throw new TypeError(`[${meta.constructor.name}.props.${prop}] ${typeof value} is not assignable to ${typeof oldValue}`)
|
||||
} else if (oldValue !== value) {
|
||||
obj[prop] = value;
|
||||
effectsMap[prop]?.forEach((f) => f(value));
|
||||
|
|
Loading…
Reference in a new issue