【优化】优化生成的typescript代码,去掉行末不必要的';'号

main
walon 2021-06-29 17:23:06 +08:00
parent ff1dd168dd
commit 260a1a84a3
4 changed files with 75 additions and 75 deletions

View File

@ -58,7 +58,7 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} {{if parent_def
} }
{{~ for field in export_fields ~}} {{~ for field in export_fields ~}}
{{field.ts_style_name}}{{if field.is_nullable}}?{{end}}: {{ts_define_type field.ctype}} readonly {{field.ts_style_name}}{{if field.is_nullable}}?{{end}}: {{ts_define_type field.ctype}}
{{~if field.gen_ref~}} {{~if field.gen_ref~}}
{{field.ts_ref_validator_define}} {{field.ts_ref_validator_define}}
{{~end~}} {{~end~}}

View File

@ -60,7 +60,7 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} {{if parent_def
} }
{{~ for field in export_fields ~}} {{~ for field in export_fields ~}}
{{field.ts_style_name}}{{if field.is_nullable}}?{{end}}: {{ts_define_type field.ctype}} readonly {{field.ts_style_name}}{{if field.is_nullable}}?{{end}}: {{ts_define_type field.ctype}}
{{~if field.gen_ref~}} {{~if field.gen_ref~}}
{{field.ts_ref_validator_define}} {{field.ts_ref_validator_define}}
{{~end~}} {{~end~}}

View File

@ -432,66 +432,66 @@ export namespace {ass.TopModule} {{
@" @"
export class Vector2 { export class Vector2 {
x: number; x: number
y: number; y: number
constructor(x: number, y: number) { constructor(x: number, y: number) {
this.x = x; this.x = x
this.y = y; this.y = y
} }
static from(_json_: any): Vector2 { static from(_json_: any): Vector2 {
let x = _json_['x']; let x = _json_['x']
let y = _json_['y']; let y = _json_['y']
if (x == null || y == null) { if (x == null || y == null) {
throw new Error(); throw new Error()
} }
return new Vector2(x, y); return new Vector2(x, y)
} }
} }
export class Vector3 { export class Vector3 {
x: number; x: number
y: number; y: number
z: number; z: number
constructor(x: number, y: number, z: number) { constructor(x: number, y: number, z: number) {
this.x = x; this.x = x
this.y = y; this.y = y
this.z = z; this.z = z
} }
static from(_json_: any): Vector3 { static from(_json_: any): Vector3 {
let x = _json_['x']; let x = _json_['x']
let y = _json_['y']; let y = _json_['y']
let z = _json_['z']; let z = _json_['z']
if (x == null || y == null || z == null) { if (x == null || y == null || z == null) {
throw new Error(); throw new Error()
} }
return new Vector3(x, y, z); return new Vector3(x, y, z)
} }
} }
export class Vector4 { export class Vector4 {
x: number; x: number
y: number; y: number
z: number; z: number
w: number; w: number
constructor(x: number, y: number, z: number, w: number) { constructor(x: number, y: number, z: number, w: number) {
this.x = x; this.x = x
this.y = y; this.y = y
this.z = z; this.z = z
this.w = w; this.w = w
} }
static from(_json_: any): Vector4 { static from(_json_: any): Vector4 {
let x = _json_['x']; let x = _json_['x']
let y = _json_['y']; let y = _json_['y']
let z = _json_['z']; let z = _json_['z']
let w = _json_['w']; let w = _json_['w']
if (x == null || y == null || z == null || w == null) { if (x == null || y == null || z == null || w == null) {
throw new Error(); throw new Error()
} }
return new Vector4(x, y, z, w); return new Vector4(x, y, z, w)
} }
} }
@ -554,57 +554,57 @@ export namespace {ass.TopModule} {{
@" @"
export class Vector2 { export class Vector2 {
x: number; x: number
y: number; y: number
constructor(x: number, y: number) { constructor(x: number, y: number) {
this.x = x; this.x = x
this.y = y; this.y = y
} }
static from(_buf_: Bright.Serialization.ByteBuf): Vector2 { static from(_buf_: Bright.Serialization.ByteBuf): Vector2 {
let x = _buf_.ReadFloat(); let x = _buf_.ReadFloat()
let y = _buf_.ReadFloat(); let y = _buf_.ReadFloat()
return new Vector2(x, y); return new Vector2(x, y)
} }
} }
export class Vector3 { export class Vector3 {
x: number; x: number
y: number; y: number
z: number; z: number
constructor(x: number, y: number, z: number) { constructor(x: number, y: number, z: number) {
this.x = x; this.x = x
this.y = y; this.y = y
this.z = z; this.z = z
} }
static from(_buf_: Bright.Serialization.ByteBuf): Vector3 { static from(_buf_: Bright.Serialization.ByteBuf): Vector3 {
let x = _buf_.ReadFloat(); let x = _buf_.ReadFloat()
let y = _buf_.ReadFloat(); let y = _buf_.ReadFloat()
let z = _buf_.ReadFloat(); let z = _buf_.ReadFloat()
return new Vector3(x, y, z); return new Vector3(x, y, z)
} }
} }
export class Vector4 { export class Vector4 {
x: number; x: number
y: number; y: number
z: number; z: number
w: number; w: number
constructor(x: number, y: number, z: number, w: number) { constructor(x: number, y: number, z: number, w: number) {
this.x = x; this.x = x
this.y = y; this.y = y
this.z = z; this.z = z
this.w = w; this.w = w
} }
static from(_buf_: Bright.Serialization.ByteBuf): Vector4 { static from(_buf_: Bright.Serialization.ByteBuf): Vector4 {
let x = _buf_.ReadFloat(); let x = _buf_.ReadFloat()
let y = _buf_.ReadFloat(); let y = _buf_.ReadFloat()
let z = _buf_.ReadFloat(); let z = _buf_.ReadFloat()
let w = _buf_.ReadFloat(); let w = _buf_.ReadFloat()
return new Vector4(x, y, z, w); return new Vector4(x, y, z, w)
} }
} }

View File

@ -57,7 +57,7 @@ namespace Luban.Job.Proto.Generate
export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if parent_def_type}}{{x.parent}}{{else}}BeanBase{{end}} { export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if parent_def_type}}{{x.parent}}{{else}}BeanBase{{end}} {
{{~if x.is_abstract_type~}} {{~if x.is_abstract_type~}}
static serializeTo(_buf_ : Bright.Serialization.ByteBuf, _bean_ : {{name}}) : void { static serializeTo(_buf_ : Bright.Serialization.ByteBuf, _bean_ : {{name}}) {
if (_bean_ == null) { if (_bean_ == null) {
_buf_.WriteInt(0) _buf_.WriteInt(0)
return return
@ -69,11 +69,11 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if pa
static deserializeFrom(_buf_ : Bright.Serialization.ByteBuf) : {{name}} { static deserializeFrom(_buf_ : Bright.Serialization.ByteBuf) : {{name}} {
let _bean_ :{{name}} let _bean_ :{{name}}
switch (_buf_.ReadInt()) { switch (_buf_.ReadInt()) {
case 0 : return null; case 0 : return null
{{~ for child in x.hierarchy_not_abstract_children~}} {{~ for child in x.hierarchy_not_abstract_children~}}
case {{child.id}}: _bean_ = new {{child.full_name}}(_buf_); break; case {{child.id}}: _bean_ = new {{child.full_name}}(_buf_); break
{{~end~}} {{~end~}}
default: throw new Error(); default: throw new Error()
} }
_bean_.deserialize(_buf_) _bean_.deserialize(_buf_)
return _bean_ return _bean_
@ -86,12 +86,12 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if pa
{{~ for field in fields ~}} {{~ for field in fields ~}}
{{field.ts_style_name}}{{if field.is_nullable}}?{{end}} : {{ts_define_type field.ctype}}; {{field.ts_style_name}}{{if field.is_nullable}}?{{end}} : {{ts_define_type field.ctype}}
{{~end~}} {{~end~}}
serialize(_buf_ : Bright.Serialization.ByteBuf) { serialize(_buf_ : Bright.Serialization.ByteBuf) {
{{~if parent_def_type~}} {{~if parent_def_type~}}
super.serialize(_buf_); super.serialize(_buf_)
{{~end~}} {{~end~}}
{{~ for field in fields ~}} {{~ for field in fields ~}}
{{ts_bin_serialize ('this.' + field.ts_style_name) '_buf_' field.ctype}} {{ts_bin_serialize ('this.' + field.ts_style_name) '_buf_' field.ctype}}
@ -100,7 +100,7 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if pa
deserialize(_buf_ : Bright.Serialization.ByteBuf) { deserialize(_buf_ : Bright.Serialization.ByteBuf) {
{{~if parent_def_type~}} {{~if parent_def_type~}}
super.deserialize(_buf_); super.deserialize(_buf_)
{{~end~}} {{~end~}}
{{~ for field in fields ~}} {{~ for field in fields ~}}
{{ts_bin_deserialize ('this.' + field.ts_style_name) '_buf_' field.ctype}} {{ts_bin_deserialize ('this.' + field.ts_style_name) '_buf_' field.ctype}}
@ -112,7 +112,7 @@ export {{if x.is_abstract_type}} abstract {{end}} class {{name}} extends {{if pa
{{~ for field in hierarchy_fields ~}} {{~ for field in hierarchy_fields ~}}
+ ""{{field.ts_style_name}}:"" + this.{{field.ts_style_name}} + "","" + ""{{field.ts_style_name}}:"" + this.{{field.ts_style_name}} + "",""
{{~end~}} {{~end~}}
+ ""}""; + ""}""
} }
} }
{{x.typescript_namespace_end}} {{x.typescript_namespace_end}}
@ -141,7 +141,7 @@ export class {{name}} extends Protocol {
{{~ for field in fields ~}} {{~ for field in fields ~}}
{{field.ts_style_name}}{{if field.is_nullable}}?{{end}} : {{ts_define_type field.ctype}}; {{field.ts_style_name}}{{if field.is_nullable}}?{{end}} : {{ts_define_type field.ctype}}
{{~end~}} {{~end~}}
serialize(_buf_ : Bright.Serialization.ByteBuf) { serialize(_buf_ : Bright.Serialization.ByteBuf) {
@ -161,7 +161,7 @@ export class {{name}} extends Protocol {
{{~ for field in fields ~}} {{~ for field in fields ~}}
+ ""{{field.ts_style_name}}:"" + this.{{field.ts_style_name}} + "","" + ""{{field.ts_style_name}}:"" + this.{{field.ts_style_name}} + "",""
{{~end~}} {{~end~}}
+ ""}""; + ""}""
} }
} }
{{x.typescript_namespace_end}} {{x.typescript_namespace_end}}