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

[조익준]TS Todo Refactor 과제 #6

Open
wants to merge 17 commits into
base: choikjun
Choose a base branch
from
Open

Conversation

harry7435
Copy link
Collaborator

📌 설명

VanillaJS 3주차 과제 Todo App을 TypeScript로 변환

🚀배포 링크

https://fedc-5-learning-ts-study.vercel.app/

✅ PR 포인트 & 궁금한 점

  • 함수형 컴포넌트를 new 생성자를 사용해서 호출할 때 명시적 any 이슈 발생
    this: any와 new 생성자를 통해 생성할 때 as any로 단언하여 임시 해결
  1. class 형태로 변환하는 것이 원시적인 문제 해결 방법
  2. class 형태로 도저히 변환이 불가능하다면 위의 방법이 최선책
  • 전역적으로 타입을 선언하는 파일 이름을 globalTypes라고 명명했습니다.
    따로 정해져 있는 관례가 있을까요?

Copy link
Collaborator

@yejinleee yejinleee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

정합성 체크도 하시고 배포까지 .. ! 역시 익준님 👍👍

타입관련되서 궁금증이 좀 많아졌는데, 익준님의 답변두 궁금하고 같이 고민할만한 것들은 내일 더 얘기해봅시다 !!
수고하셨어요 !!

Todo-ts/main.css Show resolved Hide resolved
Comment on lines +6 to +7
export const $app: QuerySelectType<HTMLElement> =
document.querySelector('.app');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 왜 export 하셨나요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 이건 아래 쪽에서 new APP 컴포넌트를 생성할 때 $target: $app 타겟으로 해당 $app 요소와 타입을 동시에 넘겨줘야 해서 export 했습니다.

Comment on lines 14 to 15
const $header: QuerySelectType<HTMLHeadingElement> =
document.createElement('h1');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const $header: HTMLHeadingElement = document.createElement("h1"); 와 뭐가 다를까요 ??

저는 const $header = document.createElement('h1'); $target && $target.appendChild($header); 이렇게 참 검사를 통한 내로잉 을 주로 사용했는데 , 어떤 방식이 더 나을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이건 createElement에 대해서도 제가 잘못 타입을 지정한 거 같네요! 굳이 타입을 지정하지 않아도 HTMLHeadingElement 타입이 추론되는 거 같습니다.

Todo-ts/src/components/App.ts Show resolved Hide resolved
Todo-ts/src/components/TodoList.ts Show resolved Hide resolved
Todo-ts/src/components/TodoForm.ts Show resolved Hide resolved
Todo-ts/src/components/TodoList.ts Show resolved Hide resolved
Todo-ts/main.css Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants