Skip to content

Pinia TS error #1085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
PixsaOJ opened this issue Aug 22, 2024 · 8 comments
Open

Pinia TS error #1085

PixsaOJ opened this issue Aug 22, 2024 · 8 comments

Comments

@PixsaOJ
Copy link

PixsaOJ commented Aug 22, 2024

app.use(pinia) gives me Typescript error.

Code example:

import { createApp, registerElement } from 'nativescript-vue'
import { createPinia } from 'pinia'

const app = createApp(App)
const pinia = createPinia()
app.use(pinia)

Error:

     ├╴  Argument of type 'Pinia' is not assignable to parameter of type 'Plugin<[]>'.
     │      Type 'Pinia' is not assignable to type 'FunctionPlugin<[]>'.
     │        Type 'Pinia' is not assignable to type '(app: App<any>) => any'.
     │          Type 'Pinia' provides no match for the signature '(app: App<any>): any'. typescript (2345) [142, 9]
@ignacio68
Copy link

You must start pinia in a separate file and import it.
This is an example

./stores/index.ts

`import { createPinia } from 'pinia';

export const pinia = createPinia();`

app.ts

`...
import { pinia } from './stores';
...

const app = createApp(App);
app.use(pinia)`

@PixsaOJ
Copy link
Author

PixsaOJ commented Sep 2, 2024

Same result. You are just abstracting the variable. That will not have a different result.

createPinia() will always return type Pinia

@PixsaOJ
Copy link
Author

PixsaOJ commented Sep 2, 2024

They talk about server mode in replies. I don't know if it helps.

https://stackoverflow.com/questions/77913735/argument-of-type-pinia-is-not-assignable-to-parameter-of-type-plugin

@rigor789
Copy link
Member

rigor789 commented Sep 2, 2024

I'm using it in my app.ts and no errors here, please post package.json to compare versions, mine is at "pinia": "2.1.7", right now - haven't updated it yet.

@PixsaOJ
Copy link
Author

PixsaOJ commented Sep 2, 2024

"pinia": "2.0.36"

"nativescript-vue": "3.0.0-rc.2",
"ts-loader": "^9.5.1",
"typescript": "^5.5.4",
"eslint": "^9.9.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"eslint-plugin-vue": "^9.27.0",
"@nativescript/android": "~8.7.0",
"@nativescript/eslint-plugin": "^0.0.4",
"@nativescript/ios": "~8.7.2",
"@nativescript-dom/core-types": "^1.0.29",
"@nativescript-dom/vue-types": "^1.0.15",
"tns-platform-declarations": "^6.5.15",

@PixsaOJ
Copy link
Author

PixsaOJ commented Sep 2, 2024

Upgrading everything fixed the issue.

Closing as the issue is outdated

@PixsaOJ PixsaOJ closed this as completed Sep 2, 2024
@PixsaOJ
Copy link
Author

PixsaOJ commented Sep 6, 2024

So, I have one branch that is working. Another branch with all deps updated. I can not point out which package is breaking. Initially thought it was @vue/typescript-plugin that gave me this error after upgrading just a little.

but then there is this warning during pnpm install:

 WARN  Issues with peer dependencies found
.
└─┬ pinia 2.1.7
  └── ✕ unmet peer vue@"^2.6.14 || ^3.3.0": found 3.2.41

@PixsaOJ PixsaOJ reopened this Sep 6, 2024
@PixsaOJ
Copy link
Author

PixsaOJ commented Sep 9, 2024

#10623

This issue happened when i upgraded and removed pnpm-lock.yaml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants