types-kit.withindexsignature.md
September 4, 2023 ยท View on GitHub
Home > types-kit > WithIndexSignature
WithIndexSignature type
Create a type that contains T, and uses the IndexSignatureType type as the index signature.
Signature:
export type WithIndexSignature<T, IndexSignatureType> = Record<
PropertyKey,
IndexSignatureType
> &
T
Example
interface Props {
a: number
b: number
}
// ExpectMatch: { a:number, b:number, [key: PropertyKey]: any }
type NewProps = WithIndexSignature<Props, string>