File tree Expand file tree Collapse file tree 3 files changed +8
-6
lines changed
test/programs/enums-string Expand file tree Collapse file tree 3 files changed +8
-6
lines changed Original file line number Diff line number Diff line change 11enum Enum {
22 X = "x" as any ,
3- Y = "y" as any
3+ Y = "y" as any ,
4+ Z = "123" as any
45}
56
67interface MyObject {
Original file line number Diff line number Diff line change 33 "definitions" : {
44 "Enum" : {
55 "enum" : [
6+ " 123" ,
67 " x" ,
78 " y"
89 ],
Original file line number Diff line number Diff line change @@ -240,16 +240,16 @@ export class JsonSchemaGenerator {
240240 if ( str === undefined ) {
241241 str = ( typ as any ) . text ;
242242 }
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 ) {
244248 // or .text for old TS
245249 let num = parseFloat ( str as string ) ;
246250 return isNaN ( num ) ? str : num ;
247- } else if ( typ . flags & ts . TypeFlags . StringLiteral ) {
248- return str ;
249251 } else if ( typ . flags & ts . TypeFlags . NumberLiteral ) {
250252 return parseFloat ( str as string ) ;
251- } else if ( typ . flags & ts . TypeFlags . BooleanLiteral ) {
252- return ( typ as any ) . intrinsicName === "true" ;
253253 }
254254 return undefined ;
255255 }
You can’t perform that action at this time.
0 commit comments