title: Define pinia state based on an interface without creating each property again manually
body: <p>I'm trying to implement state management (pinia) in a SPA. We are using typescript and I'm wondering if there is any way to define a state based on an interface without the need to type again every single property in the state. Basically, tell the state that is based on an interface and it initializes with the right structure.</p>
  <p>I can define a state to follow a specific interface structure using defineStore&lt;string, MyInterface&gt; (which is already a big win) but I'm wondering if it's possible to follow the concept of a spread operator to avoid typing all the properties of the interface in the state declaration.</p>
  <p>conceptual example</p>
  <pre><code>interface ICustomer {
      id: number;
      name: string;
      // up to 100 more properties and in some cases, nested objects based on other interfaces
  }
  
  export const useCustomersStore = defineStore&lt;string, ICustomer&gt;('customers', {
      state: () =&gt; ({
          ...ICustomer,
      }),
  ...
  </code></pre>
  <p>We have quite big interfaces (I'm talking between 50-100 properties in each one) and if we have to type each property again in the state it can get a bit verbose. I'm guessing the main problem is that the state needs a default value to be initialised but if we have to type all the properties again it will makes things a bit messier. Also, not very future proof if we have to remember to modify the state properties if we change the interfaces. Our APIs always match exactly the same interface structure as the interfaces so we are using axios specifying the interface on each call too.</p>
  <p>Thanks</p>