Skip to content

Commit

Permalink
Processing: Types: Formatting and Guard
Browse files Browse the repository at this point in the history
  • Loading branch information
tordans committed Jan 10, 2025
1 parent 6e3ea82 commit 2f6ba1d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions processing/steps/generateTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export function generateTableIdType(processedTables: string[]) {
.sort()
.map((tableName) => `'${tableName}'`)
.join(' | ')
return `export type TableId = ${unionString}`
return `export type TableId = ${unionString || 'ERROR'}`
}

/**
Expand All @@ -20,10 +20,12 @@ export async function generateTypes(processedTables: string[]) {
if (params.environment !== 'development') return

console.log('Generating types...')

const typeFilePath = join(TYPES_DIR, 'tableId.ts')
const tableIdType = generateTableIdType(processedTables)
const typeFile = Bun.file(typeFilePath)
const tableIdType = generateTableIdType(processedTables)
await Bun.write(typeFile, tableIdType)

try {
await $`bunx prettier -w --config=/processing/.prettierrc ${TYPES_DIR} > /dev/null`
} catch (error) {
Expand Down

0 comments on commit 2f6ba1d

Please sign in to comment.