| 양쪽 이전 판이전 판다음 판 | 이전 판 |
| typescript:deep:type [2019/11/23 04:37] – [Solution 3 - More specific signature:] taekgu | typescript:deep:type [2025/04/15 10:05] (현재) – 바깥 편집 127.0.0.1 |
|---|
| The syntax here is very simple, it is just like the lambda function in Java or C#, the 'string' after the arrow is the type of the return value. The para: string defines the type of the parameter. It takes a ''string'' and return a ''string''. | The syntax here is very simple, it is just like the lambda function in Java or C#, the 'string' after the arrow is the type of the return value. The para: string defines the type of the parameter. It takes a ''string'' and return a ''string''. |
| |
| | 여기 문법은 매우 단순하고, 이것은 자바와 씨샵의 라므다 함수와 유사하게 화살표후의 'string'은 반환값의 타입이다. 'para: string'은 파라메터의 타입을 선어한다. 이것은 ''문자열''을 받아서 ''문자열''을 반환한다. |
| ==== Solution 4 - Use type ==== | ==== Solution 4 - Use type ==== |
| |
| We can use ''type'' to declare a function type: | We can use ''type'' to declare a function type: |
| | |
| | ''type''을 이용하여 함수 타입을 선언할 수 있다. |
| |
| <Code:typescript> | <Code:typescript> |
| |
| We are Typescript, we'd love to use the beloved ''interface'' for everything, well, you can, for just a function. | We are Typescript, we'd love to use the beloved ''interface'' for everything, well, you can, for just a function. |
| | 우리는 타입스크립트에서는, 우리는 모든 것에 대해서 사랑하는 ''interface''를 사용를 선호한다. 글쎄, 당신은 함수에 대해서도 할 수 있다. |
| <Code:typescript> | <Code:typescript> |
| interface read { | interface read { |
| ==== Summary ==== | ==== Summary ==== |
| |
| In pratice, I often use ''Solution 4 - Type''. Maybe juse because it looks simpler than ''interface'' version. | In pratice, I often use ''Solution 4 - Type''. Maybe just because it looks simpler than ''interface'' version. |
| |
| | 경험적으로 나는 4번 Type을 선호한다. 아마도 ''interface''버전보다 단순해 보이기 때문이다. |