Skip to content

Commit 0e5506d

Browse files
committed
chore: wip
1 parent 8fd07e8 commit 0e5506d

File tree

6 files changed

+7
-10
lines changed

6 files changed

+7
-10
lines changed

fixtures/input/variable.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// @ts-nocheck
12
import process from 'node:process'
23
import type { DtsGenerationConfig } from '@stacksjs/dtsx'
34

src/extract.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { processImports, processSourceFile, processValue } from './process'
66
import { trackTypeUsage, trackValueUsage } from './track'
77
import { debugLog, normalizeType, splitObjectProperties } from './utils'
88

9-
/* eslint-disable regexp/no-super-linear-backtracking */
10-
119
/**
1210
* Extracts types from a TypeScript file and generates corresponding .d.ts content
1311
* @param filePath - Path to source TypeScript file
@@ -108,8 +106,7 @@ function extractBalancedSymbols(text: string, openSymbol: string, closeSymbol: s
108106
export function extractFunctionSignature(declaration: string): FunctionSignature {
109107
// Remove comments and clean up the declaration
110108
const cleanDeclaration = removeLeadingComments(declaration).trim()
111-
112-
const functionPattern = /^\s*(export\s+)?(async\s+)?function\s*(\*)?\s*([^(<\s]+)/
109+
const functionPattern = /^\s*(export\s+)?(async\s+)?function\s*(?:(\*)\s*)?([^(<\s]+)/
113110
const functionMatch = cleanDeclaration.match(functionPattern)
114111

115112
if (!functionMatch) {

src/is.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function isDeclarationStart(line: string): boolean {
2222
|| line.startsWith('async function ')
2323
|| line.startsWith('declare ')
2424
|| line.startsWith('declare module')
25-
|| /^export\s+(interface|type|const|function|async\s+function)/.test(line)
25+
|| /^export\s+(?:interface|type|const|function|async\s+function)/.test(line)
2626
|| line.startsWith('export async function')
2727
)
2828
}

src/process.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable regexp/no-super-linear-backtracking,regexp/optimal-quantifier-concatenation */
12
import type { ProcessingState, PropertyInfo } from './types'
23
import { cleanComments, removeLeadingComments } from './comments'
34
import { extractCleanObjectLiteral, extractFunctionSignature, extractObjectProperties } from './extract'

src/track.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/**
2-
* Regular expression patterns used throughout the module
3-
* @remarks These patterns are optimized for performance and reliability
4-
*/
1+
/* eslint-disable no-cond-assign, regexp/no-super-linear-backtracking, regexp/no-misleading-capturing-group */
2+
53
const REGEX = {
64
typePattern: /(?:typeof\s+)?([A-Z]\w*(?:<[^>]+>)?)|extends\s+([A-Z]\w*(?:<[^>]+>)?)/g,
75
} as const
@@ -11,7 +9,6 @@ const REGEX = {
119
*/
1210
export function trackUsedTypes(content: string, usedTypes: Set<string>): void {
1311
let match: any
14-
1512
while ((match = REGEX.typePattern.exec(content)) !== null) {
1613
const type = match[1] || match[2]
1714
if (type) {

src/utils.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable regexp/no-super-linear-backtracking */
12
import type { DtsGenerationConfig, ProcessingState } from './types'
23
import { readdir } from 'node:fs/promises'
34
import { extname, join } from 'node:path'

0 commit comments

Comments
 (0)