Skip to content

Commit

Permalink
formatting + possible bug in the helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
OneOfOne committed May 30, 2018
1 parent 21ae4fd commit 015014a
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
11 changes: 4 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down Expand Up @@ -99,8 +99,7 @@ class ComplexStruct {
## Command Line Usage

```
┏━ oneofone@Ava ❨✪/O/struct2ts❩ ❨master ⚡❩
┗━━➤ struct2ts -h
➤ struct2ts -h
usage: struct2ts [<flags>] [<pkg.struct>...]
Flags:
Expand Down Expand Up @@ -130,15 +129,13 @@ Args:
[<pkg.struct>] 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

Expand Down
2 changes: 1 addition & 1 deletion helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions helpers_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 015014a

Please sign in to comment.