【修复】【cfg】修复 生成Typescript读取json格式数据的代码的bug

main
walon 2021-05-01 15:04:36 +08:00
parent 428652b433
commit 5868f9bd0a
2 changed files with 3 additions and 4 deletions

View File

@ -26,8 +26,7 @@ namespace {{x.namespace}} {
export {{if x.is_abstract_type}} abstract {{end}} class {{name}} {{if parent_def_type}} extends {{x.parent}}{{end}} { export {{if x.is_abstract_type}} abstract {{end}} class {{name}} {{if parent_def_type}} extends {{x.parent}}{{end}} {
{{~if x.is_abstract_type~}} {{~if x.is_abstract_type~}}
static deserialize(_json_ : any) : {{name}} { static deserialize(_json_ : any) : {{name}} {
switch (_json_.__type__) switch (_json_.__type__) {
{
case null : return null; case null : return null;
{{~ for child in x.hierarchy_not_abstract_children~}} {{~ for child in x.hierarchy_not_abstract_children~}}
case '{{child.name}}': return new {{child.full_name}}(_json_); case '{{child.name}}': return new {{child.full_name}}(_json_);

View File

@ -97,7 +97,7 @@ namespace Luban.Job.Cfg.TypeVisitors
} }
else else
{ {
return $"{{ {fieldName} = []; for(var _ele of {jsonVarName}) {{ let _e :{type.ElementType.Apply(TypescriptDefineTypeName.Ins)};{type.ElementType.Apply(this, "_ele", "_e")} {fieldName}.push(_e);}}}}"; return $"{{ {fieldName} = []; for(let _ele of {jsonVarName}) {{ let _e :{type.ElementType.Apply(TypescriptDefineTypeName.Ins)};{type.ElementType.Apply(this, "_ele", "_e")} {fieldName}.push(_e);}}}}";
} }
} }
@ -109,7 +109,7 @@ namespace Luban.Job.Cfg.TypeVisitors
} }
else else
{ {
return $"{{ {fieldName} = []; for(var _ele of {jsonVarName}) {{ let _e : {type.ElementType.Apply(TypescriptDefineTypeName.Ins)};{type.ElementType.Apply(this, "_ele", "_e")} {fieldName}.push(_e);}}}}"; return $"{{ {fieldName} = []; for(let _ele of {jsonVarName}) {{ let _e : {type.ElementType.Apply(TypescriptDefineTypeName.Ins)};{type.ElementType.Apply(this, "_ele", "_e")} {fieldName}.push(_e);}}}}";
} }
} }