Skip to content

Typescript Error that with Extending PiniaCustomProperties #901

Discussion options

You must be logged in to vote

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 import { AxiosInstance } from 'axios' within the declare block as that doesn't work either.

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@nathanthibert
Comment options

@nathanthibert
Comment options

@BenShelton
Comment options

@nathanthibert
Comment options

Answer selected by nathanthibert
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants