diff --git a/README.md b/README.md index 6b94fff..d9f46df 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Inspired by [tkrajina/typescriptify-golang-structs](https://github.com/tkrajina/ *. `no-null` only valid for struct fields, forces creating a new class rather than using `null` in TS. *. `null` allows any field type to be `null`. -#### Example struct +## Example * Input: @@ -99,8 +99,7 @@ class ComplexStruct { ## Command Line Usage ``` -┏━ oneofone@Ava ❨✪/O/struct2ts❩ ❨master ⚡❩ -┗━━➤ struct2ts -h +➤ struct2ts -h usage: struct2ts [] [...] Flags: @@ -130,15 +129,13 @@ Args: [] List of structs to convert (github.com/you/auth/users.User, users.User or users.User:AliasUser). - - ``` ## TODO -* Use [xast](https://github.com/OneOfOne/struct2ts) to skip reflection. -* ~~Support ES6.~~ +* Use [xast](https://github.com/OneOfOne/xast) to skip reflection. * Support annoymous structs. +* ~~Support ES6.~~ ## License diff --git a/helpers.ts b/helpers.ts index 447549b..fefc342 100644 --- a/helpers.ts +++ b/helpers.ts @@ -44,7 +44,7 @@ function ToObject(o: any, typeOrCfg: any = {}, child = false): any { for (const k of Object.keys(o)) { const v: any = o[k]; if (!v) continue; - d[k] = ToObject(v, typeOrCfg[k] || '', true); + d[k] = ToObject(v, typeOrCfg[k] || {}, true); } return d; diff --git a/helpers_gen.go b/helpers_gen.go index 78cb631..22e9230 100644 --- a/helpers_gen.go +++ b/helpers_gen.go @@ -47,7 +47,7 @@ function ToObject(o: any, typeOrCfg: any = {}, child = false): any { for (const k of Object.keys(o)) { const v: any = o[k]; if (!v) continue; - d[k] = ToObject(v, typeOrCfg[k] || '', true); + d[k] = ToObject(v, typeOrCfg[k] || {}, true); } return d; @@ -101,7 +101,7 @@ function ToObject(o, typeOrCfg = {}, child = false) { const v = o[k]; if (!v) continue; - d[k] = ToObject(v, typeOrCfg[k] || '', true); + d[k] = ToObject(v, typeOrCfg[k] || {}, true); } return d; }