2023년 12월 9일
아래 코드의 변수 a,b,c,d,e의 타입은 각각 어떻게 추론될까요?
let a = 10;
const b = 20;
const c = [1, 2];
const d = [1, "hello", true];
const e = [1, 2, 3] as const;
type A = number;
type B = 20;
type C = number[];
type D = (number | string | boolean)[];
type E = [1, 2, 3];
다음 요구사항을 만족하는 Animal, DogCat(개냥이) 타입을 완성하세요
type Dog = {
name: string;
color: string;
};
type Cat = {
name: string;
age: number;
};
type Animal = never;
type DogCat = never;
type Animal = Dog | Cat;
type DogCat = Dog & Cat;