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β€’16mo 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β€’16mo ago
Unknown User
Unknown Userβ€’16mo ago
Message Not Public
Sign In & Join Server To View
erik.gh
erik.ghβ€’16mo 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
More Posts