#Create custom TypeScript types and make the available globally
48 messages · Page 1 of 1 (latest)
Check the 1 answer and see if it can suit you
How would I import that? Importing it like this: import {Message} from '~/types/ doesn't work
But yes that did get me a step closer, now I just need to import it
It should auto import
This is my index.ts in /types/ https://paste.teamhelios.dev/7LnZ15X7n2 and unfortunately it doesn't auto import
With no import ahh okay, let me try
Ahh maybe its caused by me using it in defineProps? ts const input = defineProps({ msg: { type: Message, required: true, });
So that doesn't work?
not entirely sure I will try now
it does complain tho that I am using a type as a value tho
I usually don't do the way you did there
Give me just a sec
I'm on mobile so hard to do example one sec
ReferenceError: Message is not defined
Take your time
so couple ways here
it seems you are using ts but then not at the same time
using like the required stuff
so something like
can you try
const input = defineProps<{ msg: Message }>```
by default this is required if you wanted it optional you would just use msg?: Message
hm
try this way instead and see if you get same error
type Props = {
msg: Message
}
const input = defineProps<Props>()```
should really be the same
and just a heads up
I wish it was possible but it's not yet you can't do like defineProps<Message>
it has been requested that they allow types like that to be used but not yet
that's fine 😄
so just make sure you do a interface or type that includes your custom types
Are you active on this Discord? in case I need other help
That would be awesome 🙂
so the way i put above or ```ts
interface Props {
msg: Message
}
const input = defineProps<Props>()```
is the other option using interface
anyways, if you need anymore help just shoot me a dm and ill get back to you
Thanks alot! You were a great help