Skip to Content
러닝 타입스크립트
book

러닝 타입스크립트

by 조시 골드버그, 고승원
January 2023
Beginner to intermediate
372 pages
8h 47m
Korean
Hanbit Media, Inc.
Content preview from 러닝 타입스크립트
106
2
특징
function singSongsRecursive(songs: string[], count = 0): number {
return songs.length ? singSongsRecursive(songs.slice(1), count + 1) : count;
}
화살표 함수의 경우
=>
앞에 배치됩니다.
const singSongsRecursive = (songs: string[], count = 0): number =>
songs.length ? singSongsRecursive(songs.slice(1), count + 1) : count;
함수의 반환문이 함수의 반환 타입으로 할당할 수 없는 값을 반환하는 경우 타입스크립트는 할
당 가능성 오류를 표시합니다.
다음
getSongRecordingDate
함수는
Date
|
undefined
를 반환하도록 명시적으로 선언되었
지만, 반환문 중 하나가
string
을 반환하도록 잘못 제공하고 있습니다.
function getSongRecordingDate(song: string):
Date | undefined {
switch (song) {
case "Strange Fruit":
return new Date('April 20, 1939'); // Ok
case "Greensleeves":
return ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

이펙티브 타입스크립트

이펙티브 타입스크립트

Dan Vanderkam
견고한 데이터 엔지니어링

견고한 데이터 엔지니어링

조 라이스, 맷 하우슬리
파이썬으로 살펴보는 아키텍처 패턴

파이썬으로 살펴보는 아키텍처 패턴

오현석, 해리 퍼시벌, 밥 그레고리

Publisher Resources

ISBN: 9791169210638