tyneq / Cast
Type Alias: Cast<T>
Cast<
T> =T
Defined in: src/types/utility.ts:92
Identity type - preserves T as-is with no structural transformation.
Type Parameters
| Type Parameter |
|---|
T |
Remarks
Use Cast<T> as an explicit annotation in generic contexts where inference would widen or lose the type, or where you want to document that a type is intentionally passed through unchanged. It is a zero-cost no-op at both compile time and runtime.
Example
ts
// Annotate a computed property type without changing it:
type Passthrough<T> = Cast<{ [K in keyof T]: T[K] }>;
// Use as a readable annotation instead of a bare type parameter:
function identity<T>(value: Cast<T>): T { return value; }