Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 3.2.4-2 예제코드 오류 수정 #20

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

iberis2
Copy link

@iberis2 iberis2 commented Sep 18, 2024

안녕하세요, 책의 예제를 보고 오류를 발견해서 수정 요청 드립니다.

수정사항

책 101 ~102페이지 4.인덱스드 엑세스 타입(Indexed Access Types) 예제 코드에서,
제네릭을 타입이 아닌 값으로 사용하고 있어 수정이 필요하다고 생각됩니다.

수정 전

const PromotionList = [
  { type: "product", name: "chicken" },
  { type: "product", name: "pizza" },
  { type: "card", name: "cheer-up" }, 
];

type ElementOf<T> = (typeof T)[number];

// type PromotionItemType = { type: string; name: string }
type PromotionItemType = ElementOf<PromotionList>;

수정 후

const PromotionList = [
  { type: "product", name: "chicken" },
  { type: "product", name: "pizza" },
  { type: "card", name: "chee-up" },
];

type ElementOf<T extends readonly any[]> = T[number];

// type PromotionItemType = { type: string; name: string }
type PromotionItemType = ElementOf<typeof PromotionList>;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant