File tree Expand file tree Collapse file tree 1 file changed +41
-0
lines changed
docs/playground/ko/3-7/Types and Code Flow Expand file tree Collapse file tree 1 file changed +41
-0
lines changed Original file line number Diff line number Diff line change 1+ //// { compiler: { }, order: 1 }
2+
3+ // 3.7에서는 if문 안에서
4+ // 함수의 반환 값 대신 함수를 잘못 사용하는 것을
5+ // 검사하는 기능이 추가되었습니다.
6+
7+ // 이것은 함수가 존재하는 것을 알고 있으며
8+ // if문을 항상 참으로 할 때만 적용됩니다.
9+
10+ // 선택적인 콜백과, 선택적이지 않은 콜백이 있는
11+ // 플러그인 인터페이스의 예시입니다.
12+
13+ interface PluginSettings {
14+ pluginShouldLoad ?: ( ) => void ;
15+ pluginIsActivated : ( ) => void ;
16+ }
17+
18+ declare const plugin : PluginSettings ;
19+
20+ // pluginShouldLoad가 존재하지 않을 수 있으므로,
21+ // 다음 검사는 타당합니다.
22+
23+ if ( plugin . pluginShouldLoad ) {
24+ // pluginShouldLoad가 존재할 때의 처리.
25+ }
26+
27+ // 이는 3.6 이전에서 에러가 아니었습니다.
28+
29+ if ( plugin . pluginIsActivated ) {
30+ // 플러그인이 활성화되었을 때 무언가를 처리하려고 하는데,
31+ // 메서드를 호출하는 대신
32+ // 프로퍼티로 사용했습니다.
33+ }
34+
35+ // pluginIsActivated는 언제나 존재하겠지만,
36+ // if 블록 안에서 메서드가 호출되고 있으므로
37+ // TypeScript는 검사를 허용하고 있습니다.
38+
39+ if ( plugin . pluginIsActivated ) {
40+ plugin . pluginIsActivated ( ) ;
41+ }
You can’t perform that action at this time.
0 commit comments