@@ -3,7 +3,7 @@ import { camelCase, upperFirst } from 'lodash'
3
3
const COMMENT_START = '/**'
4
4
const COMMENT_INDENT = ' * '
5
5
const COMMENT_END = ' */'
6
- const INDENT_STRING = ' '
6
+ const INDENT_STRING = ' '
7
7
8
8
export namespace TsType {
9
9
@@ -124,7 +124,7 @@ export namespace TsType {
124
124
toDeclaration ( ) {
125
125
// if there is a value associated with the identifier, declare as identifier=value
126
126
// else declare as identifier
127
- return `${ this . identifier } ${ this . value ? ( '= ' + this . value ) : '' } `
127
+ return `${ this . identifier } ${ this . value ? ( ' = ' + this . value ) : '' } `
128
128
}
129
129
130
130
toString ( ) {
@@ -144,9 +144,13 @@ export namespace TsType {
144
144
return `${ this . toType ( settings ) } `
145
145
}
146
146
toDeclaration ( settings : TsTypeSettings ) : string {
147
- return `${ this . toBlockComment ( settings ) } export ${ settings . useConstEnums ? 'const ' : '' } enum ${ this . safeId ( ) } {
148
- ${ this . enumValues . map ( _ => _ . toDeclaration ( ) ) . join ( ',\n' ) }
149
- }`
147
+ return this . toBlockComment ( settings )
148
+ + `export ${ settings . useConstEnums ? 'const ' : '' } enum ${ this . safeId ( ) } {`
149
+ + '\n'
150
+ + INDENT_STRING
151
+ + this . enumValues . map ( _ => _ . toDeclaration ( ) ) . join ( `,\n${ INDENT_STRING } ` )
152
+ + '\n'
153
+ + '}'
150
154
}
151
155
}
152
156
@@ -166,7 +170,7 @@ export namespace TsType {
166
170
return this . data
167
171
. filter ( _ => ! ( _ instanceof Null ) )
168
172
. map ( _ => _ . toSafeType ( settings ) )
169
- . join ( '& ' )
173
+ . join ( ' & ' )
170
174
}
171
175
toSafeType ( settings : TsTypeSettings ) {
172
176
return `${ this . toType ( settings ) } `
@@ -177,7 +181,7 @@ export namespace TsType {
177
181
_type ( settings : TsTypeSettings ) {
178
182
return this . data
179
183
. map ( _ => _ . toSafeType ( settings ) )
180
- . join ( '| ' )
184
+ . join ( ' | ' )
181
185
}
182
186
}
183
187
@@ -196,9 +200,11 @@ export namespace TsType {
196
200
`${ INDENT_STRING } ${ _ . type . description
197
201
? this . generateComment ( _ . type . description ) . join ( `\n${ INDENT_STRING } ` ) + `\n${ INDENT_STRING } `
198
202
: ''
199
- } ${ _ . name } ${ _ . required ? '' : '?' } : ${ _ . type . toType ( settings ) } ${
200
- settings . endPropertyWithSemicolon ? ';' : ''
201
- } `
203
+ } ${ _ . name } ${ _ . required ? '' : '?' } : ${
204
+ _ . type . toType ( settings ) . replace ( / \n / g, '\n' + INDENT_STRING )
205
+ } ${
206
+ settings . endPropertyWithSemicolon ? ';' : ''
207
+ } `
202
208
) . join ( '\n' ) }
203
209
}`
204
210
}
0 commit comments