-
Notifications
You must be signed in to change notification settings - Fork 38
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
[TypeScript & Module Typing] 코이(정인교) 미션 제출합니다. #17
[TypeScript & Module Typing] 코이(정인교) 미션 제출합니다. #17
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
안녕하세요 코이!!
미션하시느라 수고 많으셨습니다.
몇가지 코맨트도 남겼으니 확인 부탁드립니다 :D
declare function _(selector: string): HTMLElement; | ||
declare module _ { | ||
function fetch<T>(url: string, config: RequestInit): Promise<T>; | ||
function isNull<T>(value: T): boolean; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
generic T를 왜 받는건가요?
} | ||
|
||
interface CustomElement { | ||
innerHtml: (html: string) => string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
innerHtml: (html: string) => string; | |
innerHTML: (html: string) => string; |
대문자는 어떤가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다! 아까처럼 객체로 바꾸면 대문자로 써도 되겠네요~!
const element = document.querySelector<HTMLElement>(selector); | ||
|
||
if (element === null) { | ||
throw new Error("Element is null"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
innerHTML이나 그런 함수를 쓸때 error를 뿜는건 어떨까요?
document.querySelector도 element를 못찾았다고 해서 Error을 뿜지는 않으니까요!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니다!
element.addEventListener(type, handler); | ||
}; | ||
|
||
element.show = show; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
생각못한 부분인데 좋네요!!
export function fetch() { | ||
return {}; | ||
} | ||
export function fetch<T>(url: string, config: RequestInit): Promise<T> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fetch에 generic T를 받았는데, return fetch에서는 T를 사용하고 있지 않네요!
https://stackoverflow.com/questions/41103360/how-to-use-fetch-in-typescript
여기를 참고해 주세요 :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이렇게도 가능하군요 !! 감사합니당. 지금은 지우는게 낫겠네요!
"baseUrl": ".", | ||
"declaration": true, | ||
"declarationDir": "./lib", | ||
"emitDeclarationOnly": true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
왜 declrartion만 emit하기로 결정한건가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 제거해야겠어요
"name": "ts-module", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
main 수정해주세요!
test('`_("").addEvent()`~~~~', () => {}); | ||
test("hidden 동작 확인", () => { | ||
const buttonElement = _("button.test-btn"); | ||
buttonElement.style.display = "block"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
show 함수를 사용해주세요 :D
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
좋습니당
const buttonElement = _("button.test-btn"); | ||
buttonElement.style.display = "block"; | ||
buttonElement.hide(); | ||
expect(buttonElement.style.display).toBe("hidden"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(buttonElement.style.display).toBe("hidden"); | |
expect(buttonElement.style.display).toBe("none"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
앗 none이 맞겠네요 😅
test('`_("").hidden()`~~~~', () => {}); | ||
test("show 동작 확인", () => { | ||
const buttonElement = _("button.test-btn"); | ||
buttonElement.style.display = "hidden"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
buttonElement.style.display = "hidden"; | |
buttonElement.style.display = "none"; |
🔥 팀 미션 적용 결과
본 미션을 수행하며 경험, 영감, 학습한 내용을 팀 미션에 전파해주세요.
✅ 요구사항 구현 확인
DOM 유틸
유틸
🧐 공유
/_ 작업하면서 든 생각, 질문, 새롭게 학습하거나 시도해본 내용 등등 공유할 사항이 있다면 자유롭게 적어주세요 _/
npm 패키지
아직 팀프로젝트에 반영하지는 않았습니다