Skip to content

Commit

Permalink
fix: 🐛 genInterface prop with non word chars
Browse files Browse the repository at this point in the history
  • Loading branch information
KylianB authored and Morgbn committed Jun 4, 2024
1 parent d7ff3f5 commit dc345f4
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/typeGenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ function genInterface (schema: Schema, interfaceName: string, stack: Stack): str
if (propSchema.description) {
str += ` /**${['', ...propSchema.description.trim().split('\n')].join('\n * ')}\n */\n`
}
str += ` ${propSchema.readOnly ? 'readonly ' : ''}${propName}${schema.required?.includes(propName) ? '' : '?'}: `
const match = propName.match('\\W')
str += ` ${propSchema.readOnly ? 'readonly ' : ''}${match ? "'" : ''}${propName}${match ? "'" : ''}${schema.required?.includes(propName) ? '' : '?'}: `

const propInterfaceName = `${interfaceName}${capFirst(propName)}`
const propInterfaceName = `${interfaceName}${capFirst(propName.replace(/\W/g, ''))}`
if (propSchema.type === 'array') {
const itemInterfaceName = `${propInterfaceName}Item`
if (Array.isArray(propSchema.items)) {
Expand Down

0 comments on commit dc345f4

Please sign in to comment.