While this may appear to be a straightforward question, I have not been able to find any discussions on this topic.
Currently using Vue3 with script setup
Objective:
In short: I am attempting to utilize a child type definition to specify one key of an interface object and then apply it as props within a component. However, I am encountering a TypeScript error (shown in the first image).
The issue arises when importing a type file (Platform.ts
) into an interface file (CardProps.ts
), followed by importing and utilizing the interface as props for a card component (PromptCard.vue
). No error occurs if I exclude the child type Platform
with unions from the CardProps interface.
TS Error:
Despite rendering correctly, VSCode displays the following error: https://i.sstatic.net/Lpg7K.jpg
I recently came across a VueSchool tutorial mentioning that imported interfaces cannot be used for props (requiring them to remain in the same file). However, despite this warning, everything seems to be functioning properly. Could this error be the reason behind such instruction?
Platform type
https://i.sstatic.net/Oehh7.jpg
Child type inside of CardProps interface
https://i.sstatic.net/HdZVe.jpg
Passing props to Card from Market page
https://i.sstatic.net/rANu6.jpg