const chaining = await Promise.resolve('hi')
      .then(() => {
        return 123;
      })
    ...
    // const chaining: number
    

    then에는 TResult1, TResult2 두 개의 타입 매개변수가 있습니다. 이들이 어떻게 추론되는지 확인해야 합니다. then 메서드의 첫 번째 매개변수인 onfulfilled는 함수입니다. 타입이 ((value : T) => TResult1 | PromiseLike<TResult1>)으로 되어 있으므로 PromiseLike가 무엇인지 확인해야 합니다.

    lib.es5.d.ts

    interface PromiseLike<T> {
      then<TResult1 = T, TResult2 = never>(
        onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | undefined | null,
        onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | undefined | null
      ): PromiseLike<TResult1 | TResult2>;
    }
    
    신간 소식 구독하기
    뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.