From 510f88d6d23d2d9da7ec4b6cfe41bcf166b9c34c Mon Sep 17 00:00:00 2001 From: LastLeaf Date: Fri, 8 Sep 2023 16:14:10 +0800 Subject: [PATCH] feat: add warning when `value` and `default` are both given in one property (#66) --- glass-easel/src/behavior.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glass-easel/src/behavior.ts b/glass-easel/src/behavior.ts index 2274d1f..5a8a0e9 100644 --- a/glass-easel/src/behavior.ts +++ b/glass-easel/src/behavior.ts @@ -1467,6 +1467,10 @@ export class Behavior< else if (type === NormalizedPropertyType.Boolean) value = false else if (type === NormalizedPropertyType.Array) value = [] else value = null + } else if (propDef.default !== undefined) { + triggerWarning( + `the initial value of property "${name}" is not used when its default is provided (when preparing behavior "${is}").`, + ) } let observer: ((newValue: any, oldValue: any) => void) | null if (typeof propDef.observer === 'function') {