Skip to content

Udemy/Ts/section2/23 #28

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

Merged
merged 29 commits into from
Sep 1, 2024
Merged

Udemy/Ts/section2/23 #28

merged 29 commits into from
Sep 1, 2024

Conversation

4BFC
Copy link
Member

@4BFC 4BFC commented Sep 1, 2024

✍Udemy/Ts/section2/23

본 PR은 청강 1회독을 마친 후 N회독으로 작성된 PR입니다.

🔥KeyWord

  • literal Type
  • error TS2365

📝Description

  • literal Type
    • 🚩: literal type의 예시 코드
    • 리터럴 타입은 특정 변수나 어떤 타입이어야 하는지 정의하는게 아니다. 단진 정확히 어떤 값인지 정의하는 것이다. 이를 확인하기 위해서는 마우스를 원하는 값에 호버하면 반환되는 값이 무엇인지 확인이 된다. 여기서 오해가 되면 안되는 것은 n1: number 는 일반적인 타입을 저정한 방식이다. literal Type방식은 n1: 'isNumber'와 같이 작성이 되어야 한다. 이 또한 함수에서 일반적으로 로직을 구성할 때 많이 사용된다.
  • error TS2365
    • 🐛 : error ts2365 에러의 원인 분석와 이유
    • 첫 번째 if문에 || resultConversion === 'as-number'의 조건을 n1, n2 외 추가하면서 발생한 error이다. Ts기준 조건문에서의 논리적 흐름이 충분히 명확하지 않아 발생할 수 있는 결과이다. 따라서 이 코드에서 TypeScript는 n1과 n2가 string 타입일 가능성이 있다고 판단, 인자들을 사용할 때 더 명확한 타입을 요구 따라 '+'를 추가하면 된다. 이는 리터럴 타입과는 무관하다.

📌Summary

  • 타입스크립트를 배우면서 타입들을 더 세부적으로 나눌 수 있으며 로직이 복잡해지면서 더욱 디테일한 타입들을 요구한다는 것을 알게 되었다.

4BFC and others added 29 commits August 27, 2024 01:50
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 작성한 커밋입니다.
Github에서 작성한 커밋입니다.
Github에서 수정한 커밋입니다.
Github에서 수정한 커밋입니다.
@4BFC 4BFC added the 2회독 회독 label Sep 1, 2024
@4BFC 4BFC added this to the Udemy:TypeScript milestone Sep 1, 2024
@4BFC 4BFC self-assigned this Sep 1, 2024
@4BFC 4BFC merged commit f745d48 into UdemyTs Sep 1, 2024
@4BFC 4BFC linked an issue Sep 1, 2024 that may be closed by this pull request
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2회독 회독
Projects
None yet
Development

Successfully merging this pull request may close these issues.

section2/23
1 participant