You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Requested behavior:
An intersection type of Fruit & Veggies
ie the following:
typeFruitAndVeggies='Apple'&'Carrot';
Actual behavior:
typeFruitAndVeggies=never
Use Case
Writing a Vue application with Typescript and using Vuex. I have used enums to enforce type strictness on the names of the mutations, actions and getters similar to the following:
Doing it this way however prevents me from using the Mutations = Module1Mutations | Module2Mutations type as an argument to commit mutations, if one of my <module>Mutations enums is empty (due to commit(type: string). I have created a workaround, but this feature would be nice if other people are also interested in it. Also if anyone has an appropriate solution that I haven't though of suggestions are welcome 😁
Thanks for Typescript!
The text was updated successfully, but these errors were encountered:
'Apple' & 'Carrot' is indeed never because no string can be equal to 'Apple' but also be equal to 'Carrot'. Could you provide a simpler example of what you're trying to do?
Of course, having it explained that way makes my question seem dumb haha. Basically I have a situation like the following:
2 enums with string values
A union type of both, which is essentially a union type of all the possible string values (correct me if I'm wrong)
The second that one of the enums is empty, the union type is no longer a union of strings, and therefore cannot be the parameter for a function requiring a string argument.
TypeScript Version: 2.6.1
Code
Requested behavior:
An intersection type of Fruit & Veggies
ie the following:
Actual behavior:
Use Case
Writing a Vue application with Typescript and using Vuex. I have used enums to enforce type strictness on the names of the mutations, actions and getters similar to the following:
Doing it this way however prevents me from using the
Mutations = Module1Mutations | Module2Mutations
type as an argument to commit mutations, if one of my<module>Mutations
enums is empty (due tocommit(type: string)
. I have created a workaround, but this feature would be nice if other people are also interested in it. Also if anyone has an appropriate solution that I haven't though of suggestions are welcome 😁Thanks for Typescript!
The text was updated successfully, but these errors were encountered: