Typescript Error that with Extending PiniaCustomProperties #901
-
I'm having some issues with typing a plugin for Axios for all my stores. The extensions.d.ts
store.ts (the store creation file)
useUserStore.ts
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
I know this is very similar to #388, which I followed, though I still get those errors/non-typing. |
Beta Was this translation helpful? Give feedback.
-
You need to change your declaration file slightly. You can't import from a different module when trying to do declaration merging outside of the declare block. This is common gotcha, you can track reports of it at microsoft/TypeScript#28097. Try this: import "pinia";
declare module "pinia" {
export interface PiniaCustomProperties {
api: import('axios').AxiosInstance; // use an inline import
}
} EDIT: Removed example using |
Beta Was this translation helpful? Give feedback.
You need to change your declaration file slightly. You can't import from a different module when trying to do declaration merging outside of the declare block. This is common gotcha, you can track reports of it at microsoft/TypeScript#28097.
Try this:
EDIT: Removed example using
import { AxiosInstance } from 'axios'
within thedeclare
block as that doesn't work either.