Types have no overlap, but i have defined the type so that it does in fact have overlap

This is the error that i am getting `This comparison appears to be unintentional because the types '"KVA"' and '"XYZ"' have no overlap.ts(2367)`` Why is this not working 🙂 ?
4 Replies
erik.gh
erik.gh•2y ago
because the type of TYPE is not actually your union but the exact string "KVA" so it can never be "XYZ"
erik.gh
erik.gh•2y ago
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
erik.gh
erik.gh•2y ago
i also tried it with let but that does not change anything as ts knows that the value will never be redeclared i think this is only an example as it does not make sense to me why you would have conditions based on a hardcoded value TESTTYPE will always be "KVA" based on that condition so you could also just:
const TESTTYPE = "KVA"
const TESTTYPE = "KVA"
Want results from more Discord servers?
Add your server