Skip to content

Commit

Permalink
chore: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbbreuer committed Oct 21, 2024
1 parent c5125b2 commit 359bea6
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function generateDtsTypes(sourceCode: string): string {
let value = trimmed.slice(equalIndex + 1).trim()

// Handle multi-line object literals
if (value.startsWith('{') && !value.endsWith('}')) {
if (value.startsWith('{')) {
let bracketCount = 1
let i = 1
while (bracketCount > 0 && i < value.length) {
Expand All @@ -59,9 +59,7 @@ export function generateDtsTypes(sourceCode: string): string {
bracketCount--
i++
}
if (i < value.length) {
value = value.slice(0, i)
}
value = value.slice(0, i)
}

const declaredType = name.includes(':') ? name.split(':')[1].trim() : null
Expand Down Expand Up @@ -107,9 +105,10 @@ export function generateDtsTypes(sourceCode: string): string {
let currentPair = ''
let inQuotes = false
let bracketCount = 0
let escapeNext = false

for (const char of content) {
if (char === '"' || char === '\'') {
if (!escapeNext && (char === '"' || char === '\'')) {
inQuotes = !inQuotes
}
else if (!inQuotes) {
Expand All @@ -126,6 +125,7 @@ export function generateDtsTypes(sourceCode: string): string {
else {
currentPair += char
}
escapeNext = char === '\\' && !escapeNext
}

if (currentPair.trim()) {
Expand Down

0 comments on commit 359bea6

Please # to comment.