Skip to content

allow non-string template params via lightweight inspect()#3

Merged
gmaclennan merged 2 commits into
mainfrom
feat/non-string-params
Mar 3, 2026
Merged

allow non-string template params via lightweight inspect()#3
gmaclennan merged 2 commits into
mainfrom
feat/non-string-params

Conversation

@gmaclennan

Copy link
Copy Markdown
Member

Summary

  • Adds a built-in inspect() utility to stringify non-string template parameters (numbers, objects, arrays, dates, maps, sets, etc.)
  • String params remain unquoted for backward compatibility
  • Fixes bugs in the inspect function: Invalid Date handling, depth-independent rendering of Error/RegExp/Date types, and correct shared (non-circular) reference detection
  • Widens TypeScript param types from string to unknown

Test plan

  • All 46 existing tests still pass unchanged
  • 17 new integration tests covering: number, boolean, null, undefined, object, array, Error, nested depth, circular refs, shared refs, Date, Invalid Date, Map, Set, mixed types, backward-compat string, custom message, RegExp
  • New tsd type tests for non-string param values
  • npm test passes (both runtime and type tests)

🤖 Generated with Claude Code

gmaclennan and others added 2 commits March 3, 2026 10:09
Params of any type (numbers, objects, arrays, etc.) are now stringified
using a built-in inspect() utility. String params remain unquoted for
backward compatibility. Includes bug fixes: Invalid Date handling,
depth-independent rendering of Error/RegExp/Date, and correct shared
(non-circular) reference handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Wrap inspect in try-catch so getters, proxies, or overridden
  prototype methods that throw never crash error construction
- Truncate large collections (arrays, objects, Maps, Sets) at 50 items
- Truncate long nested strings at 200 chars
- Use Map/Set forEach instead of spread to avoid iterator-based attacks
- Add TypedArray support (renders as e.g. Uint8Array([ 1, 2, 3 ]))

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gmaclennan gmaclennan merged commit 589d34f into main Mar 3, 2026
3 checks passed
@gmaclennan gmaclennan deleted the feat/non-string-params branch March 3, 2026 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant