From bb698e7b9919cd955166cc1b7bc57267b830872a Mon Sep 17 00:00:00 2001 From: kangwei Date: Mon, 22 Jun 2020 21:11:34 +0800 Subject: [PATCH] use undef for null --- packages/designer/src/document/node/props/prop.ts | 9 ++++----- packages/designer/src/document/node/props/props.ts | 4 ++-- packages/types/src/value-type.ts | 2 +- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/designer/src/document/node/props/prop.ts b/packages/designer/src/document/node/props/prop.ts index fadbdbf8b..755a74e93 100644 --- a/packages/designer/src/document/node/props/prop.ts +++ b/packages/designer/src/document/node/props/prop.ts @@ -109,11 +109,11 @@ export class Prop implements IPropParent { } return this.items!.map((prop) => { const v = prop.export(stage); - return v === UNSET ? null : v; + return v === UNSET ? undefined : v; }); } - return null; + return undefined; } private _code: string | null = null; @@ -176,7 +176,7 @@ export class Prop implements IPropParent { this._code = null; const t = typeof val; if (val == null) { - this._value = null; + this._value = undefined; this._type = 'literal'; } else if (t === 'string' || t === 'number' || t === 'boolean') { this._type = 'literal'; @@ -192,7 +192,6 @@ export class Prop implements IPropParent { } else { this._type = 'map'; } - this._type = 'map'; } else { this._type = 'expression'; this._value = { @@ -206,7 +205,7 @@ export class Prop implements IPropParent { @computed getValue(): CompositeValue { const v = this.export(TransformStage.Serilize); if (v === UNSET) { - return null; + return undefined; } return v; } diff --git a/packages/designer/src/document/node/props/props.ts b/packages/designer/src/document/node/props/props.ts index 3e7cabbce..1da17eda7 100644 --- a/packages/designer/src/document/node/props/props.ts +++ b/packages/designer/src/document/node/props/props.ts @@ -106,7 +106,7 @@ export class Props implements IPropParent { this.items.forEach(item => { let value = item.export(stage); if (value === UNSET) { - value = null; + value = undefined; } let name = item.key as string; if (name && typeof name === 'string' && name.startsWith(EXTRA_KEY_PREFIX)) { @@ -129,7 +129,7 @@ export class Props implements IPropParent { } let value = item.export(stage); if (value === UNSET) { - value = null; + value = undefined; } if (typeof name === 'string' && name.startsWith(EXTRA_KEY_PREFIX)) { name = getOriginalExtraKey(name); diff --git a/packages/types/src/value-type.ts b/packages/types/src/value-type.ts index d0e083160..9918d2a3b 100644 --- a/packages/types/src/value-type.ts +++ b/packages/types/src/value-type.ts @@ -27,7 +27,7 @@ export interface JSBlock { } // JSON 基本类型 -export type JSONValue = boolean | string | number | null | JSONArray | JSONObject; +export type JSONValue = boolean | string | number | null | undefined | JSONArray | JSONObject; export type JSONArray = JSONValue[]; export interface JSONObject { [key: string]: JSONValue;