File tree 3 files changed +8
-6
lines changed
test/programs/enums-string
3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 1
1
enum Enum {
2
2
X = "x" as any ,
3
- Y = "y" as any
3
+ Y = "y" as any ,
4
+ Z = "123" as any
4
5
}
5
6
6
7
interface MyObject {
Original file line number Diff line number Diff line change 3
3
"definitions" : {
4
4
"Enum" : {
5
5
"enum" : [
6
+ " 123" ,
6
7
" x" ,
7
8
" y"
8
9
],
Original file line number Diff line number Diff line change @@ -240,16 +240,16 @@ export class JsonSchemaGenerator {
240
240
if ( str === undefined ) {
241
241
str = ( typ as any ) . text ;
242
242
}
243
- if ( typ . flags & ts . TypeFlags . EnumLiteral ) {
243
+ if ( typ . flags & ts . TypeFlags . StringLiteral ) {
244
+ return str ;
245
+ } else if ( typ . flags & ts . TypeFlags . BooleanLiteral ) {
246
+ return ( typ as any ) . intrinsicName === "true" ;
247
+ } else if ( typ . flags & ts . TypeFlags . EnumLiteral ) {
244
248
// or .text for old TS
245
249
let num = parseFloat ( str as string ) ;
246
250
return isNaN ( num ) ? str : num ;
247
- } else if ( typ . flags & ts . TypeFlags . StringLiteral ) {
248
- return str ;
249
251
} else if ( typ . flags & ts . TypeFlags . NumberLiteral ) {
250
252
return parseFloat ( str as string ) ;
251
- } else if ( typ . flags & ts . TypeFlags . BooleanLiteral ) {
252
- return ( typ as any ) . intrinsicName === "true" ;
253
253
}
254
254
return undefined ;
255
255
}
You can’t perform that action at this time.
0 commit comments