Typescript 28

(2장) System of a Clown - 2. Clown Availability

https://github.com/LearningTypeScript/projects/tree/main//projects/the-type-system/system-of-a-clown/02-clown-availability 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 pro..

(2장) System of a Clown - 1. Clowning Around

https://github.com/LearningTypeScript/projects/tree/main//projects/the-type-system/system-of-a-clown/01-clowning-around 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 projec..

(1장) The Typeinator - 3. Callbacks to Async Await

https://github.com/LearningTypeScript/projects/tree/main//projects/from-javascript-to-typescript/the-typeinator/03-callbacks-to-async-await 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-..

(1장) The Typeinator - 2. Prototypes to Classes

https://github.com/LearningTypeScript/projects/tree/main//projects/from-javascript-to-typescript/the-typeinator/02-prototypes-to-classes 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 ..

(1장) The Typeinator - 1. Syntactic Sugar

https://github.com/LearningTypeScript/projects/tree/main//projects/from-javascript-to-typescript/the-typeinator/01-syntactic-sugar 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 w..

7장 연습문제

interface UserID { } class API { getLoggedInUserId(): Option { return _Option("something") } getFriendIds(userID: UserID): Option { return _Option([]) } getUserName(userID: UserID): Option { return _Option("test") } } const api = new API const result = api.getLoggedInUserId().flatMap(_ => api.getFriendIds(_)).flatMap(_ => api.getUserName(_)) Option의 내부에 api 호출의 결과(실패할 수도 있는)를 집어넣어서 에러를 처리해야 하는데,..

6장 연습문제

/* 1. 첫 번째 타입 T, 두 번째 타입 U a. 가능하다 T U c. 가능하다 T U g. 가능하다 T < U h. 가능하다 T < U i. 가능하다 T = U j. 불가능하다 T와 U가 서로소 집합 k. 가능하다 (같은 반환형에 더 넓은 매개변수) l. 불가능하다 (서로 다른 열거형) 2. keyof O = 'a' O['a']['b'] = c : string */ //T = string | boolean | number , U = boolean | number | string[] 3. type Exclusive = Exclude | Exclude /* type A = 1 |..

5장 연습문제

//1번. 인터페이스는 타입만 가지고 있는 반면 클래스는 실제 값과 타입을 모두 가질 수 있다. //2번.상속은 가능하지만 인스턴스화 할 수 없다. 상속받은 클래스 또한 인스턴스화 할 수 없다. class testA { protected constructor( public Name: string ) { } } const test1 = new testA("name1");//Constructor of class 'testA' is protected and only accessible within the class declaration. class testB extends testA {} const test2 = new testB("name2")//Constructor of class 'testA' is pr..

4장 연습문제

//1. 함수의 반환형을 추론한다. 컨택스트로부터 매개변수 타입을 추론할 때도 있다.(ex : 콜백 함수의 경우) //2. 제공하지 않는다. Rest 매개변수로 대체해야 한다. //3. type Reserve = { (from: Date, to:Date, destination: string): void (from: Date, destination : string ): void (destination: string ) : void } const reserve: Reserve = ( fromOrDestination : Date | string, toOrDestination? : Date | string, destination? : string ) => { if(toOrDestination instanceof..

3장 연습문제

1번 let a = 1042 //number let b = "apples" //string const c= "pineapples"//string const d = [true, true, false] //boolean[] const e = {type: "ficus"} // {type:string} const f = [1, false] // (number|boolean)[] const g = [3] // number[] let h = null // null h는 null일 줄 알았는데 any였다. 2번 //a let i:3 = 3 i = 4 //리터럴 타입 3으로 지정됐다 //b let j = [1,2,3] j.push(4) j.push('5') //초기에 number[] 타입으로 정해졌다 //c let k..

728x90