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 예제 코드 오류 수정 #16

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

redcontroller
Copy link

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

수정사항

인덱스드 엑세스 타입 예제 코드에 수정사항이 있습니다.
(1) PromotionList 객체 배열의 마지막 요소에 오타가 있어 변경: chee-up -> cheer-up
※ 출판 도서에서는 수정 되어 있음. 대신 객체에 쉼표가 없음...
(2) 인덱스드 엑세스 타입 부분에 에러가 발생해서 수정: (아래 참조)

수정 전

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

type ElementOf<T> = (typeof T)[number]; // Error: 'T' only refers to a type, but is being used as a value here.
// type PromotionItemType = { type: string; name: string }
type PromotionItemType = ElementOf<PromotionList>; // Error: 'PromotionList' refers to a value, but is being used as a type here.

수정 후

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

// type PromotionItemType = { type: string; name: string }
type PromotionItemType = typeof PromotionList[number];

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