As a newcomer to TypeScript and the Vue Composition API, I encountered an error that left me puzzled:
I have a component that requires an api
variable as a prop, which should be of type AxiosInstance
:
export default defineComponent({
props: {
api: AxiosInstance,
(...)
However, when I attempt to specify the type
of the prop as AxiosInstance
, I receive the following error message:
TS2693: 'AxiosInstance' only refers to a type, but is being used as a value here.
This error is perplexing to me because I believe I am using types as values within this prop object. For example, I have another prop defined like so:
fileExtensionFilter: {
type: String,
default: undefined
},
How can I correctly specify the type for this api
prop?