I am playing with prettier on my vue.ts project. (composition API)
I have one file where I have to specify the type of the prop using type assertion inside template tag. Without brackets around statement, style highlighting breaks and when I save the file, prettier formats the file and removes it.
this is ok:
<ItemColors :item="(chosenItem as Item)" />
this one breaks the styles:
<ItemColors :item="chosenItem as Item"/>
I have fixed the issue using
prettier-ignore
added before the component.
The project is quite big and I don't know if I will need to do the same in other files, so I will have to repeat pasting the line elsewhere. May be there is some generic solution for this? fine highlight broken highlight
const chosenItem = ref<Item | null>(null)2.const onItemDown = (e: CustomEvent) => {const pressedItem = e.detail.item as Item | null; chosenItem.value = pressedItem}, onItemDown is triggered as CustomEvent as you see, desired instance is located in e.detail.item, I am again asserting type here since type is any. So when I pass this chosenItem in template I receive error that types are not assignable for some reason. I didn't know what can I do except asserting the type...