강의

멘토링

커뮤니티

Inflearn Community Q&A

yjmm's profile image
yjmm

asked

TypeScript A-Z: Learn by Following

Generics (1)

interface에서 n개의 Generices설정가능한가요? | 7분 27초

Written on

·

92

0

interface Vehicle<T> {
    name: string;
    color: T;
    option: T;
}

질문1. Generics과 n개의 제네릭타입설정

강사님의 예시는 1개의 Generics를 이용하셨는데

위의 코드와 같이 만약에 n개의 Generics타입을 지정할 수도 있을까요??

 

질문2. 만약 n개의 제네릭타입이 가능하다면?

어떻게 코드를 수정할 수 있을까요??

const car: Vehicle<{price: number}> = {
    name: 'Car',
    color: 'red',
    option: {
        price: 1000
    }
}
javascripttypescript

Answer

This question is waiting for answers
Be the first to answer!
yjmm's profile image
yjmm

asked

Ask a question