()
| 19 | } |
| 20 | |
| 21 | public toTS(): string { |
| 22 | const { type } = this |
| 23 | |
| 24 | const enumVariants = `{ |
| 25 | ${indent(type.values.map((v) => `${v}: ${this.getValue(v)}`).join(',\n'), TAB_SIZE)} |
| 26 | } as const` |
| 27 | const enumBody = this.isStrictEnum() ? `runtime.makeStrictEnum(${enumVariants})` : enumVariants |
| 28 | |
| 29 | return `export const ${type.name} = ${enumBody} |
| 30 | |
| 31 | export type ${type.name} = (typeof ${type.name})[keyof typeof ${type.name}]\n` |
| 32 | } |
| 33 | |
| 34 | private getValue(value: string): string { |
| 35 | return this.isObjectEnum() ? value : `'${value}'` |
nothing calls this directly
no test coverage detected