Skip to content

Commit 4714cca

Browse files
committed
chore: wip
1 parent 4d49453 commit 4714cca

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/extract.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,15 @@ function processConstDeclaration(declaration: string, isExported = true): string
151151
const lines = declaration.split('\n')
152152
const firstLine = lines[0]
153153
const name = firstLine.split('const')[1].split('=')[0].trim().split(':')[0].trim()
154+
const typeMatch = firstLine.match(/const\s+\w+\s*:\s*([^=]+)\s*=/)
154155

156+
if (typeMatch) {
157+
// If a type is defined, use it directly in the generated declaration
158+
const type = typeMatch[1].trim()
159+
return `${isExported ? 'export ' : ''}declare const ${name}: ${type};`
160+
}
161+
162+
// If no type is defined, process the properties as before
155163
const properties = lines.slice(1, -1).map((line) => {
156164
let inString = false
157165
let stringChar = ''

0 commit comments

Comments
 (0)