Phantom
Defined in: node_modules/.pnpm/@web3-storage+data-segment@5.3.0/node_modules/@web3-storage/data-segment/dist/src/api.d.ts:422
A utility type to retain an unused type parameter T
.
Similar to phantom type parameters in Rust.
Capturing unused type parameters allows us to define “nominal types,” which TypeScript does not natively support. Nominal types in turn allow us to capture semantics not represented in the actual type structure, without requiring us to define new classes or pay additional runtime costs.
For a concrete example, see ByteView, which extends the Uint8Array
type to capture
type information about the structure of the data encoded into the array.
Type Parameters
Section titled “Type Parameters”Type Parameter |
---|
T |
Properties
Section titled “Properties”[Marker]?
Section titled “[Marker]?”optional [Marker]: T;
Defined in: node_modules/.pnpm/@web3-storage+data-segment@5.3.0/node_modules/@web3-storage/data-segment/dist/src/api.d.ts:423