also looking at this
chore(deps): update all non-major dependencies
#2997
29 files
+1047
-444
| @@ -64,6 +64,12 @@ export function processVariableDeclaration(decl: Declaration, keepComments: bool | ||
| 64 | 64 | // Add comments if present |
| 65 | 65 | const comments = formatComments(decl.leadingComments, keepComments) |
| 66 | 66 | |
| 67 | // Fast path: if we have an explicit type annotation and no value needing special inference, | |
| 68 | // use the scanner's pre-built text directly | |
| 69 | if (decl.typeAnnotation && !decl.value) { | |
| 70 | return comments + decl.text | |
| 71 | } | |
| 72 | ||
| 67 | 73 | let result = '' |
| 68 | 74 | |
| 69 | 75 | // Add export if needed |
| @@ -197,11 +203,14 @@ export function processTypeDeclaration(decl: Declaration, keepComments: boolean | ||
| 197 | 203 | result += 'declare ' |
| 198 | 204 | } |
| 199 | 205 | |
| 200 | // Extract the type definition from the original text | |
| 201 | // Remove leading/trailing whitespace and comments | |
| 202 | const typeMatch = decl.text.match(/type\s[^=]+=\s*([\s\S]+)/) | |
| 203 | if (typeMatch) { | |
| 204 | const typeDef = typeMatch[0].replace(/;?\s*$/, '') | |
| 206 | // Extract the type definition from the original text using indexOf instead of regex | |
| 207 | const typeIdx = decl.text.indexOf('type ') | |
| 208 | if (typeIdx !== -1) { | |
| 209 | let typeDef = decl.text.slice(typeIdx) | |
| 210 | // Strip trailing semicolons and whitespace | |
| 211 | let end = typeDef.length | |
| 212 | while (end > 0 && (typeDef.charCodeAt(end - 1) === 59 /* ; */ || typeDef.charCodeAt(end - 1) === 32 || typeDef.charCodeAt(end - 1) === 10 || typeDef.charCodeAt(end - 1) === 13)) end-- | |
| 213 | if (end < typeDef.length) typeDef = typeDef.slice(0, end) | |
| 205 | 214 | result += typeDef |
| 206 | 215 | } |
| 207 | 216 | else { |
| @@ -260,10 +269,10 @@ export function processEnumDeclaration(decl: Declaration, keepComments: boolean | ||
| 260 | 269 | // Add enum name |
| 261 | 270 | result += decl.name |
| 262 | 271 | |
| 263 | // Extract the body from the original text | |
| 264 | const bodyMatch = decl.text.match(/\{[\s\S]*\}/) | |
| 265 | if (bodyMatch) { | |
| 266 | result += ` ${bodyMatch[0]}` | |
| 272 | // Extract the body from the original text using indexOf instead of regex | |
| 273 | const enumBraceIdx = decl.text.indexOf('{') | |
| 274 | if (enumBraceIdx !== -1) { | |
| 275 | result += ' ' + decl.text.slice(enumBraceIdx) | |
| 267 | 276 | } |
| 268 | 277 | else { |
| 269 | 278 | result += ' {}' |
| @@ -280,8 +289,10 @@ export function processImportDeclaration(decl: Declaration): string { | ||
| 280 | 289 | // Just ensure they end with semicolon |
| 281 | 290 | let result = decl.text.trim() |
| 282 | 291 | |
| 283 | // Remove any existing semicolon to avoid doubles | |
| 284 | result = result.replace(/;+$/, '') | |
| 292 | // Remove trailing semicolons without regex | |
| 293 | let end = result.length | |
| 294 | while (end > 0 && result.charCodeAt(end - 1) === 59 /* ; */) end-- | |
| 295 | if (end < result.length) result = result.slice(0, end) | |
| 285 | 296 | |
| 286 | 297 | // Add single semicolon |
| 287 | 298 | result += ';' |
| @@ -320,10 +331,10 @@ export function processModuleDeclaration(decl: Declaration, keepComments: boolea | ||
| 320 | 331 | // Add module name |
| 321 | 332 | result += decl.name |
| 322 | 333 | |
| 323 | // Extract the body from the original text | |
| 324 | const bodyMatch = decl.text.match(/\{[\s\S]*\}/) | |
| 325 | if (bodyMatch) { | |
| 326 | result += ` ${bodyMatch[0]}` | |
| 334 | // Extract the body from the original text using indexOf | |
| 335 | const modBraceIdx = decl.text.indexOf('{') | |
| 336 | if (modBraceIdx !== -1) { | |
| 337 | result += ' ' + decl.text.slice(modBraceIdx) | |
| 327 | 338 | } |
| 328 | 339 | else { |
| 329 | 340 | result += ' {}' |
| @@ -351,10 +362,10 @@ export function processModuleDeclaration(decl: Declaration, keepComments: boolea | ||
| 351 | 362 | // Add namespace name |
| 352 | 363 | result += decl.name |
| 353 | 364 | |
| 354 | // Extract the body from the original text | |
| 355 | const bodyMatch = decl.text.match(/\{[\s\S]*\}/) | |
| 356 | if (bodyMatch) { | |
| 357 | result += ` ${bodyMatch[0]}` | |
| 365 | // Extract the body from the original text using indexOf | |
| 366 | const nsBraceIdx = decl.text.indexOf('{') | |
| 367 | if (nsBraceIdx !== -1) { | |
| 368 | result += ' ' + decl.text.slice(nsBraceIdx) | |
| 358 | 369 | } |
| 359 | 370 | else { |
| 360 | 371 | result += ' {}' |