Skip to content

Commit 015014a

Browse files
committed
formatting + possible bug in the helpers
1 parent 21ae4fd commit 015014a

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

README.md

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Inspired by [tkrajina/typescriptify-golang-structs](https://github.com/tkrajina/
2323
*. `no-null` only valid for struct fields, forces creating a new class rather than using `null` in TS.
2424
*. `null` allows any field type to be `null`.
2525

26-
#### Example struct
26+
## Example
2727

2828
* Input:
2929

@@ -99,8 +99,7 @@ class ComplexStruct {
9999
## Command Line Usage
100100

101101
```
102-
┏━ oneofone@Ava ❨✪/O/struct2ts❩ ❨master ⚡❩
103-
┗━━➤ struct2ts -h
102+
➤ struct2ts -h
104103
usage: struct2ts [<flags>] [<pkg.struct>...]
105104
106105
Flags:
@@ -130,15 +129,13 @@ Args:
130129
[<pkg.struct>] List of structs to convert (github.com/you/auth/users.User,
131130
users.User or users.User:AliasUser).
132131
133-
134-
135132
```
136133

137134
## TODO
138135

139-
* Use [xast](https://github.com/OneOfOne/struct2ts) to skip reflection.
140-
* ~~Support ES6.~~
136+
* Use [xast](https://github.com/OneOfOne/xast) to skip reflection.
141137
* Support annoymous structs.
138+
* ~~Support ES6.~~
142139

143140
## License
144141

helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ function ToObject(o: any, typeOrCfg: any = {}, child = false): any {
4444
for (const k of Object.keys(o)) {
4545
const v: any = o[k];
4646
if (!v) continue;
47-
d[k] = ToObject(v, typeOrCfg[k] || '', true);
47+
d[k] = ToObject(v, typeOrCfg[k] || {}, true);
4848
}
4949

5050
return d;

helpers_gen.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ function ToObject(o: any, typeOrCfg: any = {}, child = false): any {
4747
for (const k of Object.keys(o)) {
4848
const v: any = o[k];
4949
if (!v) continue;
50-
d[k] = ToObject(v, typeOrCfg[k] || '', true);
50+
d[k] = ToObject(v, typeOrCfg[k] || {}, true);
5151
}
5252
5353
return d;
@@ -101,7 +101,7 @@ function ToObject(o, typeOrCfg = {}, child = false) {
101101
const v = o[k];
102102
if (!v)
103103
continue;
104-
d[k] = ToObject(v, typeOrCfg[k] || '', true);
104+
d[k] = ToObject(v, typeOrCfg[k] || {}, true);
105105
}
106106
return d;
107107
}

0 commit comments

Comments
 (0)