Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 22, 2024
1 parent 4d49453 commit 4714cca
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,15 @@ function processConstDeclaration(declaration: string, isExported = true): string
const lines = declaration.split('\n')
const firstLine = lines[0]
const name = firstLine.split('const')[1].split('=')[0].trim().split(':')[0].trim()
const typeMatch = firstLine.match(/const\s+\w+\s*:\s*([^=]+)\s*=/)

if (typeMatch) {
// If a type is defined, use it directly in the generated declaration
const type = typeMatch[1].trim()
return `${isExported ? 'export ' : ''}declare const ${name}: ${type};`
}

// If no type is defined, process the properties as before
const properties = lines.slice(1, -1).map((line) => {
let inString = false
let stringChar = ''
Expand Down

0 comments on commit 4714cca

Please # to comment.