Typescript/러닝 타입스크립트 연습문제

(4장) Various Lawyerings - 1.Aviary Classification

띵킹 2023. 4. 12. 19:34

 

 

https://github.com/LearningTypeScript/projects/tree/main//projects/objects/various-lawyerings/01-aviary-classification

 

GitHub - LearningTypeScript/projects: Hands-on real world projects that will help you exercise your knowledge of TypeScript.

Hands-on real world projects that will help you exercise your knowledge of TypeScript. - GitHub - LearningTypeScript/projects: Hands-on real world projects that will help you exercise your knowledg...

github.com

세계적으로 저명한 조류법 전문가로서 
법원에 다양한 조류의 특성과 관련 조류 정보를 제대로 교육하는 것이 저의 의무입니다. 
Bird 파일이 제대로 정리되지 않으면 중요한 임무를 수행할 수 없습니다.

제 birds 배열을 위한 객체 타입 Bird를 만들어주세요.
가능한 타입을 구체적으로 지정해주시길 바랍니다.
name 프로퍼티를 제외한 다른 string 타입은 모두 리터럴의 유니언으로 적어주세요.

## 파일
index.ts: 여기에 객체의 타입을 작성해주세요
index.test.ts: 테스트
solution.ts: 솔루션 코드
// Write your Bird type here! ✨
type Bird = {
	name : string
	diet : "omnivore" | "carnivore"
	dangerous? : boolean
	noisy? : boolean
	intelligent? : boolean
}
export const birds: Bird[] = [
	{
		dangerous: true,
		diet: "omnivore",
		name: "White-Throated Magpie-Jay",
		noisy: true,
	},
	{
		diet: "omnivore",
		intelligent: true,
		name: "Eurasian Magpie",
	},
	{
		diet: "carnivore",
		name: "Yellow-Billed Blue Magpie",
		noisy: true,
	},
	{
		intelligent: true,
		diet: "omnivore",
		name: "American Crow",
	},
];

객체 타입을 작성하는 간단한 문제

728x90