1- /* eslint-disable no-console */
2- // ===========================
3- // Type Definitions
4- // ===========================
1+ /* eslint-disable no-console,regexp/no-super-linear-backtracking */
52
63/**
74 * Regular expression patterns used throughout the module
@@ -41,12 +38,17 @@ export interface RegexPatterns {
4138 readonly exportCleanup : RegExp
4239 /** Default export */
4340 readonly defaultExport : RegExp
44-
41+ /** Named export */
4542 readonly complexType : RegExp
43+ /** Union and intersection types */
4644 readonly unionIntersection : RegExp
45+ /** Conditional types */
4746 readonly mappedType : RegExp
47+ /** Conditional types */
4848 readonly conditionalType : RegExp
49+ /** Generic constraints */
4950 readonly genericConstraints : RegExp
51+ /** Function overload */
5052 readonly functionOverload : RegExp
5153}
5254
@@ -67,7 +69,6 @@ export const REGEX: RegexPatterns = {
6769 regularImport : / i m p o r t \s * \{ ( [ ^ } ] + ) \} \s * f r o m \s * [ ' " ] ( [ ^ ' " ] + ) [ ' " ] / ,
6870
6971 // Type and return patterns
70- // eslint-disable-next-line regexp/no-super-linear-backtracking
7172 typeAnnotation : / : \s * ( \{ [ ^ = ] + \} | \[ [ ^ \] ] + \] | [ ^ = ] + ?) \s * = / ,
7273
7374 // Bracket matching
@@ -79,7 +80,6 @@ export const REGEX: RegexPatterns = {
7980 asyncFunction : / ^ (?: e x p o r t \s + ) ? a s y n c \s + f u n c t i o n / ,
8081 genericParams : / ^ ( [ a - z _ $ ] [ \w $ ] * ) \s * ( < [ ^ ( ] + > ) / i,
8182 functionParams : / \( ( [ \s \S ] * ?) \) (? = \s * : ) / ,
82- // eslint-disable-next-line regexp/no-super-linear-backtracking
8383 functionReturnType : / \) \s * : \s * ( [ \s \S ] + ?) (? = \{ | $ ) / ,
8484 functionName : / ^ ( [ ^ ( < \s ] + ) / ,
8585
@@ -96,13 +96,9 @@ export const REGEX: RegexPatterns = {
9696 defaultExport : / e x p o r t \s + d e f a u l t \s + / ,
9797
9898 // New patterns for complex types
99- // eslint-disable-next-line regexp/no-super-linear-backtracking
10099 complexType : / t y p e \s + ( [ ^ = < ] + ) (?: < [ ^ > ] + > ) ? \s * = \s * ( [ ^ ; ] + ) / ,
101- // eslint-disable-next-line regexp/no-super-linear-backtracking
102100 unionIntersection : / ( [ ^ | & ] + ) (?: \s * [ | & ] \s * ( [ ^ | & ] + ) ) + / ,
103- // eslint-disable-next-line regexp/no-super-linear-backtracking
104101 mappedType : / \{ \s * \[ \s * ( [ ^ \] ] + ) i n \s * ( [ ^ \] ] + ) \] : / ,
105- // eslint-disable-next-line regexp/no-super-linear-backtracking
106102 conditionalType : / ( [ ^ e x t n d s ] + ) \s + e x t e n d s \s + ( [ ^ ? ] + ) \? \s * ( [ ^ : ] + ) : \s * ( [ ^ ; ] + ) / ,
107103 genericConstraints : / < ( [ ^ > ] + ) > / ,
108104 functionOverload : / ^ (?: e x p o r t \s + ) ? (?: d e c l a r e \s + ) ? f u n c t i o n \s + ( [ ^ ( < \s ] + ) / ,
@@ -1903,6 +1899,7 @@ function trackTypeUsage(content: string, state: ImportTrackingState): void {
19031899 // Only look for capitalized type references that are actually used in declarations
19041900 const typePattern = / (?: e x t e n d s | i m p l e m e n t s | : | < ) \s * ( [ A - Z ] [ a - z A - Z 0 - 9 ] * (?: < [ ^ > ] + > ) ? ) / g
19051901 let match
1902+ // eslint-disable-next-line no-cond-assign
19061903 while ( ( match = typePattern . exec ( content ) ) !== null ) {
19071904 const typeName = match [ 1 ] . split ( '<' ) [ 0 ] // Handle generic types
19081905 state . usedTypes . add ( typeName )
@@ -1925,6 +1922,7 @@ function trackValueUsage(content: string, state: ImportTrackingState, dtsLines?:
19251922
19261923 for ( const pattern of patterns ) {
19271924 let match
1925+ // eslint-disable-next-line no-cond-assign
19281926 while ( ( match = pattern . exec ( content ) ) !== null ) {
19291927 const values = match [ 1 ] . split ( ',' ) . map ( v => v . trim ( ) )
19301928 for ( const value of values ) {
0 commit comments