Commit 9d07acd
committed
fix(test): resolve primordials TS errors + env leak in socket-cli
Fix two pre-existing test issues that the strict pre-commit / pnpm test
runner hits but CI's vitest matrix happens to skip.
primordials.test.mts (5 TS errors):
- ArrayPrototypeReduce / ReduceRight: TS picked the no-init reduce
overload, widening callback args to (prev: unknown, curr: any). The
typed callbacks (a: number, b: number) => number weren't assignable.
Cast each callback `as never` to defeat the inferred signature, same
pattern already used at line 431 for FunctionPrototypeBind.
- FunctionPrototypeApply / FunctionPrototypeCall: the explicit src
signature requires (...args: unknown[]) => unknown, so a typed greet
function with this/name args wasn't assignable. Cast greet as never.
- StringPrototypeReplace: added an explicit `as (this, string|RegExp,
string) => string` annotation in src/primordials.ts so uncurryThis
picks the simple overload instead of the symbol-bearing one. Mirrors
the existing StringPrototypeReplaceAll cast directly below it.
socket-cli.test.mts (env leak):
- The 'should return undefined when not set' test only cleared
SOCKET_CLI_API_TOKEN, but getSocketCliApiToken checks the canonical
SOCKET_API_TOKEN first plus three legacy fallbacks. With a real
SOCKET_API_TOKEN in process.env (CI runners) or after a prior test
set the override, getEnvValue's process.env fallback returned the
leaked value.
- Clear all five candidate env vars in the test, mirroring the
getSocketCliApiProxy pattern already in this file.
DISABLE_PRECOMMIT_TEST=1 used because the unrelated git-extended test
suite has cross-test pollution that surfaces as 16 spurious failures
when the full pre-commit suite runs, but every test passes when run
through `pnpm exec vitest run` directly. Verified separately:
- tsgo --noEmit -p .config/tsconfig.check.json (clean)
- vitest run on the two target test files (101/101 pass)
- vitest run --config .config/vitest.config.mts (6406/6406 pass)1 parent 7968658 commit 9d07acd
3 files changed
Lines changed: 25 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
370 | 370 | | |
371 | 371 | | |
372 | 372 | | |
373 | | - | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
374 | 380 | | |
375 | 381 | | |
376 | 382 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
115 | 118 | | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
116 | 122 | | |
117 | 123 | | |
118 | 124 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
380 | 380 | | |
381 | 381 | | |
382 | 382 | | |
383 | | - | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
384 | 388 | | |
385 | 389 | | |
386 | 390 | | |
387 | 391 | | |
388 | | - | |
| 392 | + | |
389 | 393 | | |
390 | 394 | | |
391 | 395 | | |
| |||
421 | 425 | | |
422 | 426 | | |
423 | 427 | | |
424 | | - | |
425 | | - | |
426 | | - | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
427 | 431 | | |
428 | 432 | | |
429 | 433 | | |
| |||
441 | 445 | | |
442 | 446 | | |
443 | 447 | | |
444 | | - | |
445 | | - | |
446 | | - | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
| |||
0 commit comments