@cqrs-ddd/untyped
A typed replacement for as any when code must read a property the type does not
declare, such as framework metadata on a wrapper object. untyped(value) returns the
same value typed as T & Record<string | symbol, unknown>: declared properties keep
their types, and every other property reads as unknown, so the caller must narrow it.
It satisfies Biome’s noExplicitAny without suppressing the rule.
Installation
Section titled “Installation”Requires Node.js 22.12 or later. No dependencies, no framework.
Published as an ES module; a CommonJS application loads it with require().
| Export | Signature | Description |
|---|---|---|
untyped |
<T>(value: T) => T & Record<string | symbol, unknown> |
The same value, with undeclared properties typed unknown |
It changes only the type; the value is returned as is.
Examples
Section titled “Examples”Read a symbol-keyed property that a library sets on an object it hands you:
Declared properties keep their types, so only the undeclared read needs narrowing:
License
Section titled “License”Dual-licensed under AGPLv3 and a Commercial License. See the root
LICENSE and
COMMERCIAL_LICENSE.txt
for details.