function destructuring({ prop: { nested } }: { prop: { nested: string }}) {}
    destructuring({ prop: { nested: 'hi' }});
    

    함수 내부에서 this를 사용하는 경우에는 명시적으로 표기해야 합니다. 표기하지 않으면 any로 추론되고, 에러가 발생합니다.

    function example1() {
      console.log(this);
    }
    // 'this' implicitly has type 'any' because it does not have a type annotation.
    
    function example2(this: Window) {
      console.log(this);
    }
    // this: Window
    
    function example3(this: Document, a: string, b: 'this') {}
    example3('hello', 'this');
    // The 'this' context of type 'void' is not assignable to method's 'this' of type 'Document'.
    
    example3.call(document, 'hello', 'this');
    
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.