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

type level equal operator #13

Open
humonnom opened this issue Sep 4, 2022 · 0 comments
Open

type level equal operator #13

humonnom opened this issue Sep 4, 2022 · 0 comments
Assignees

Comments

@humonnom
Copy link
Collaborator

humonnom commented Sep 4, 2022

  • Conditional Types check

    • T extends X ? 1 : 2
  • isTypeIdenticalTo를 사용하기 위한 술책

    • 조건부 타입에서 T가 정해지지 않으면 deferred되는 것을 활용한다.
    • deferred된 conditional types는 isTypesIdenticalTo라는 내부 함수에 의존한다.
    • 두개의 conditional types가 같은 것으로 판명이 나려면 아래의 조건에 해당해야 한다.
      1. 두 조건 유형이 동일한 제약 조건을 갖습니다.
      2. 두 조건의 참 분기와 거짓 분기가 동일한 유형입니다.

  • 동일성을 체크하고자 하는 Type 두 개를 각각 조건 유형으로 만든다.

    • (<T>() => T extends X ? 1 : 2)
    • (<T>() => T extends Y ? 1 : 2)
  • 두개의 조건 유형 끼리의 비교를 내부 함수인 isTypeIdenticalTo에 의존하여 수행


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

No branches or pull requests

1 participant