Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 | 31 |
Tags
- Regexp
- ai로 앱 만들기
- 개발자
- 빠른 서버
- iframe
- multiprocessing
- Domination Game
- XFrameOptions
- typescript
- 리더
- 좋은 리더란
- 2인 사무실
- 공유 오피스
- 동료리뷰
- javascript
- select css
- 스타트업
- 느린 서버
- 테드스페이스
- html
- python
- JS
- React
- 구로 디지털 단지 사무실
- 구로 공유 오피스
- turborepo
- select tag
- PM
- css
- Django
Archives
- Today
- Total
목록Overloading (1)
개발하는 일상
Typescript Function Overloading의 설명과 사용법(Function return type based on input parameter)
왜 Overloading이 필요할까? typescript에서 함수를 정의하다보면 인자를 어떻게 주느냐에 따라 return type이 다르게 잡혔으면 싶을 때가 있습니다. 예를 들면, function read(str?: string) { return str } const word = read('hello world') // string | undefined 여기서 함수 read의 return type은 str에 의해 결정되는 것이 아니라 항상 string|undefined 형태의 union type을 갖습니다. 즉, word의 type은 string | undefined 입니다. 'hello world'의 type은 string인데도 말이죠. 이럴때 함수를 여러번 쌓아서 정의하면(overloading) 문..
개발 간단 팁
2022. 6. 22. 01:59