Skip to content

createORM() can't be passed to pinia.use #1813

@MartinX3

Description

@MartinX3

Discussed in #1754

Originally posted by erikjalevik December 22, 2023
I wanted to give this project a spin as it looks quite neat for what we need but I'm failing at the very first hurdle.

On trying to add pinia-orm to pinia, there's immediately a TypeScript error. Here's my code:

import { createORM } from 'pinia-orm';
const pinia = createPinia();
pinia.use(createORM());

TS says:

Argument of type '() => { use(plugin: PiniaOrmPlugin): any; }' is not assignable to parameter of type 'PiniaPlugin'.
  Type '{ use(plugin: PiniaOrmPlugin): any; }' is not assignable to type 'void | Partial<PiniaCustomProperties<string, StateTree, _GettersTree<StateTree>, _ActionsTree> & PiniaCustomStateProperties<...>>'.ts(2345)

I also get

ERROR(vue-tsc)  Argument of type '() => { use(plugin: PiniaOrmPlugin): any; }' is not assignable to parameter of type 'PiniaPlugin'.
  Type '{ use(plugin: PiniaOrmPlugin): any; }' is not assignable to type 'void | Partial<PiniaCustomProperties<string, StateTree, _GettersTree<StateTree>, _ActionsTree> & PiniaCustomStateProperties<...>>'.

adding this plugin to pinia using Quasar + Vite.

Template: https://github.com/MartinX3/pinia_orm_quasar_ts_error_test

I just did

  1. pnpm create quasar
    1. With qusar cli, vite 5, typescript, scss, script setup, etc.
  2. pnpm add pinia-orm
  3. .use(createORM())
  4. Updated the deps (but it happens without this step, too)
  5. quasar dev

It works with:

// @ts-expect-error TODO Workaround for https://github.com/CodeDredd/pinia-orm/discussions/1754 & https://github.com/CodeDredd/pinia-orm/issues/1813
  pinia.use(createORM())

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions