brunch

You can make anything
by writing

C.S.Lewis

by brunchdev Aug 29. 2022

Type에서 Promise 제거하기


Awaited로 타입을 씌워 주면 된다.

// A = string
type A = Awaited<Promise<string>>;


주의점은 겹쳐진 Promise를 모두 제거해준다는 점!

// B = number
type B = Awaited<Promise<Promise<number>>>;


참고

https://devblogs.microsoft.com/typescript/announcing-typescript-4-5/#awaited-type

https://stackoverflow.com/questions/48944552/typescript-how-to-unwrap-remove-promise-from-a-type


이전 08화 NextJS Link 경고
brunch book
$magazine.title

현재 글은 이 브런치북에
소속되어 있습니다.

작품 선택
키워드 선택 0 / 3 0
댓글여부
afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari