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",
|
"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",
|
"description": "A zero-dependency, ~600 Bytes (minified & gzipped), JS base class for creating reactive custom elements easily",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|
|
@ -134,6 +134,8 @@ export class WebComponent extends HTMLElement {
|
||||||
effectsMap[prop] = [];
|
effectsMap[prop] = [];
|
||||||
}
|
}
|
||||||
effectsMap[prop].push(value.callback);
|
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) {
|
} else if (oldValue !== value) {
|
||||||
obj[prop] = value;
|
obj[prop] = value;
|
||||||
effectsMap[prop]?.forEach((f) => f(value));
|
effectsMap[prop]?.forEach((f) => f(value));
|
||||||
|
|
Loading…
Reference in a new issue