`typeof` at the type level captures the type of an existing value, and utilities like `ReturnType<T>` and `Parameters<T>` extract pieces of a function type, keeping types in sync with implementation.
ts
function createWallet(seed: string, index: number) {
return { address: `0x${seed}${index}`, index };
}
type Wallet = ReturnType<typeof createWallet>;
// { address: string; index: number }
type CreateWalletArgs = Parameters<typeof createWallet>;
// [seed: string, index: number]
function replay(args: CreateWalletArgs): Wallet {
return createWallet(...args);
}Deriving types this way means if `createWallet`'s signature changes, `Wallet` and `CreateWalletArgs` update automatically — no manually maintained duplicate interface can drift out of sync.