Skip to content

Commit

Permalink
fix: generate valid type declarations for generated enum terms
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRose committed Dec 7, 2021
1 parent 0774cb9 commit 4750c03
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions cli/src/render/client/renderClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,17 @@ export function renderEnumsMaps(
return enums
.map(
(type) =>
`${declaration}${camelCase('enum' + type.name)} = {\n` +
`${declaration}${camelCase('enum' + type.name)}${moduleType === 'type' ? ': ' : ' = '}{\n` +
type
.getValues()
.map((v) => {
if (!v?.name) {
return ''
}
return ` ${v.name}: '${v.name}'`
return ` ${moduleType === 'type' ? 'readonly ' : ''}${v.name}: '${v.name}'`
})
.join(',\n') +
`\n}${moduleType === 'type' ? ' as const' : ''}\n`,
`\n}\n`,
)
.join('\n')
}
Expand Down

0 comments on commit 4750c03

Please sign in to comment.