[Vuejs]-Initialize Pinia store with a type

1👍

The error you are encoutring tells that the file from where you try to import Ticket does not have a default export so if you didn’t define a default export you have to import this way:

import {Ticket} from '...'; // with curly brackets

about what you want to achieve, the function is returning an object (key-value), it may be of type Ticket but you cannot replace it with Ticket because Ticket is a type, not an object.
you still can define a return type for the function, but this will not avoid specifying the values of the returned object:

state: (): Ticket => ({
  id: null,
  status: "",
  subject: "",
  email: "",
  department: null,
  ticketType: null,
})

Leave a comment