When I call
gapi.client.storage.buckets.list()
, TypeScript gives me an error saying "Property 'storage' does not exist on type 'typeof client'."
This issue is occurring within a Vue.js application where I am utilizing the GAPI library.
To address this problem, I have already installed the following packages: @types/gapi
, @types/gapi.auth2
, @types/gapi.client
, and @types/gapi.client.storage
. TypeScript can correctly recognize types for methods like gapi.load()
, gapi.client.init()
, and gapi.auth2.getAuthInstance()
.
Nevertheless, despite my efforts, I continue to encounter errors specifically with the
gapi.client.storage.buckets.list()
call:
ERROR in /Users/olance/Dev/project/src/views/Editor.vue(29,38):
29:38 Property 'storage' does not exist on type 'typeof client'.
27 |
28 | async mounted() {
> 29 | this.buckets = await gapi.client.storage.buckets.list({ project: "storage-cloud-editor" });
| ^
30 | }
31 |
Version: typescript 3.5.3
In my tsconfig.json
file under compilerOptions
, I have included the following:
"typeRoots": [
"node_modules/@types"
],
"types": [
"webpack-env", "vuetify", "gapi", "gapi.auth2", "gapi.client.storage", "gapi.client"
],
The default configuration only had "types": ["webpack-env"]
, but modifying it as shown above was the only way I could resolve the issue. However, removing any of these options causes the compiler to fail elsewhere in the code (particularly related to vuetify, which lacks type declarations in @types
).
What steps are still needed to ensure that TypeScript recognizes the definitions for gapi.client.storage
?