Generic interfaces describe object shapes that can hold different value types.

Generic Interfaces

interfaces.ts
interface Box<T> {
    label: string;
    value: T;
}

function describeBox<T>(box: Box<T>): string {
    return `${box.label}=${box.value}`;
}

const quantity: number = ;
const countBox: Box<number> = { label: "items", value: quantity };
const text: string = describeBox<number>(countBox);

console.log(text);
interface Box<T> {
    label: string;
    value: T;
}

function describeBox<T>(box: Box<T>): string {
    return `${box.label}=${box.value}`;
}

const quantity: number = ;
const countBox: Box<number> = { label: "items", value: quantity };
const text: string = describeBox<number>(countBox);

console.log(text);
interface Box<T> {
    label: string;
    value: T;
}

function describeBox<T>(box: Box<T>): string {
    return `${box.label}=${box.value}`;
}

const quantity: number = ;
const countBox: Box<number> = { label: "items", value: quantity };
const text: string = describeBox<number>(countBox);

console.log(text);
generic interface A generic interface uses a type parameter inside an object shape.