강의

멘토링

커뮤니티

Inflearn Community Q&A

shleecloud's profile image
shleecloud

asked

Advanced TypeScript skills learned through hands-on practice

How to use generic const - Solving the problem

제네릭 const 활용법 섹션에서 에러가 발생합니다.

Resolved

Written on

·

245

1

stackblitz에 공유해주신 링크대로 따라가는데, 28-constraints-with-const-annotations.solution.1, 2 파일에서
제네릭에 설정한 const의 에러가 발생합니다.

 

export const narrowFruits = <const TFruits extends FruitsConstraint>(
  t: TFruits
) => t;

 

A 'const' assertions can only be applied to references to enum members, or string, number, boolean, array, or object literals.(1355)


typescript

Answer 1

1

aftercamp님의 프로필 이미지
aftercamp
Instructor

https://www.typescriptlang.org/play

제 IDE나 위 링크에서 테스트 해보면 문제가 없는데, 아마 StackBlitz 문제일 것 같아서 그 쪽에 문의를 넣었습니다! 임시로 위 링크에서 코드 돌려보시면 될 것 같습니다.

shleecloud's profile image
shleecloud

asked

Ask a question