Typescript generics

is the following code generic?

export default interface IField<I = object, O = I> {
    set(value: I): void;
    get(): O;
}

Why is it written I = object ?

Mar.29,2022

default type, if there is an I type defined, that type is I, if there is no definition, the type is object.


interface Card {
    name: string
    age: number
}

interface IField<I = Card, O = I> {
    set(value: I): void;
    get(): O;
}

// I,OI
const map: IField<string, number> = {
    set(value: string) { },
    get: () => 1,
}


// extends ,


interface List<I extends Card, O extends I> {
    set(value: I): void;
    get(): O;
}

//  I Card
// const myList: List<Date, Date> = {     
const myList: List<Card, Card> = {
    set(value: Card) { },
    get: () => {
        return {
            name: 'xiaoming',
            age: 15
        }
    },
}
Menu