Polymorphism - 다향성; 다른 모양의 코드를 가질 수 있게 해주는 것; interface SStorage { [key: string]: T } class LocalStorage { private storage: SStorage = {} set(key: string, value: T) { this.storage[key] = value; } remove(key: string) { delete this.storage[key] } get(key: string): T { return this.storage[key] } clear(){ this.storage = {} } } const stringStorage = new LocalStorage() stringStorage.get("hi") // : str..
interface & type interface는 오로지 object의 모양을 typescript에게 설명해 주기 위해서만 사용된다. type Team = "red" | "blue" | "yellow" // ok // interface Team = "red" | "blue" | "yellow" // X // interface Tema = string //X type Player = { name: string team: Team } interface Player { name: string team: Team } // 상속 type User = { name: string } interface Player extends User { ~~~~ } type Player = User & { ~~~~ } // 인터페..
Classes 1. 기본 Class TypeScript private, public 개념 있음 class Person { constructor( private firstName: string, private lastName: string, public nickname: string ){} } const bibliya = new Person("bibliya", "seo", "비블리야"); bibliya.firstName // Error JavaScript private, public 개념 없음 class Person { constructor(firstName, lastName, nickname) { this.firstName = firstName; this.lastName = lastName; this.n..
Call Signatures type Add = (a: number, b: number) => number; const add: Add = (a, b) => a + b Overloading //overloading은 함수가 여러개의 call signatures를 가지고 있을 때 발생 type Add = { (a: number, b: number) : number (a: number, b: string) : number } const add: Add = (a, b) => a + b; //error const add: Add = (a, b) => { if(typeof b === "string") return a return a + b } // 아무 의미 없는 코드 // Nextjs에서 일어나는 overloa..
숫자(Number) let myNum: number = 6; 문자열(String) let color: string = "pink"; color = 'red'; 불리언(Boolean) let isFinished: boolean = false; 배열(String) let numberList: number[] = [1, 2, 3]; let stringList: string[] = ["1","2","3"]; 튜플(Tuple) let array: [string, number]; array = ["hello", 1]; //ok 열거 (Enum) enum Color {Red, Green, Pink} let myColor: Color = Color.Green; enum Color {Red = 1, Green, Pink..
- Total
- Today
- Yesterday
- React
- 파이어베이스버전9
- firebaseorderby
- nextredirect
- nextjsseo
- mediaprint
- cssmodules
- firebasecollection
- typescriptfunction
- 웹소캣
- websocekt
- Socket
- reduxtoolkit
- nextrewrite
- TypeScript
- serversiderendering
- 웹인쇄
- typescriptinterface
- nextjsrouter
- typescriptclass
- webhook이란
- firebasev9
- NextJS
- nextjscss
- 404pages
- nextjsjsx
- reactquill
- reactjs
- stylesjsx
- Router
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | |||
| 5 | 6 | 7 | 8 | 9 | 10 | 11 |
| 12 | 13 | 14 | 15 | 16 | 17 | 18 |
| 19 | 20 | 21 | 22 | 23 | 24 | 25 |
| 26 | 27 | 28 | 29 | 30 |
