Skip to content

section2/20: error TS2367 #26

Open
@4BFC

Description

@4BFC

✍Udemy/Ts/section2/20

🔗Reference

🐞ErroCode

  • error TS2367
    src/app.ts:18:5 - error TS2367: This comparison appears to be unintentional because the types 'Role.READ_ONLY' and 'Role.ADMIN' have no overlap.
    

📝Description

  • enum으로 key, value를 생성하고 person 객체에 role 속성에 enum의 key들로 초기값을 주었다. 이후 비교 연산으로 각기 다른 log를 확인하기 위한 코드를 작성했으나 이와 같은 에러가 발생했다. 원인 발생의 명확한 사유는 모르겠으나 Ts의 타입추론에서 발생한 문제로 여겨진다. 또는 아직 enum을 사용하는 방법을 잘 몰라서 발생한 문제로 여겨지고 있다. 이의 문제를 해결하게 된다면 해당 issue를 언급해서 해결하면 된다.

💡Solution

  • 아직 명확한 솔루션을 찾지 못했음.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions