如何在 googleapis 中使用 Typescript 类型(特别是使用 drive_v3 时的文件类型)
How to use Typescript types with googleapis (specifically the File type when using drive_v3)
这是我的 package.json
:
"dependencies": {
"googleapis": "^50.0.0"
}
我的 index.ts
文件中有这个:
import {drive_v3} from "googleapis";
const {Schema$File} = drive_v3.Schema$File
console.log({x:Schema$File})
tsc
告诉我:
error TS2339: Property 'Schema$File' does not exist on type 'typeof drive_v3'.
但是当我查看 .d.ts
文件时,我可以看到是否在那里声明
使用 drive_v3 api 时,导入“Google 驱动器文件”类型的正确方法是什么?
聚会迟到了,但你可以做到这一点
import { drive_v3 } from 'googleapis'
type DriveFile = drive_v3.Schema$File
const file: DriveFile = ....
或者只使用 drive_v3.Schema$File
而不是重新分配它。
这是我的 package.json
:
"dependencies": {
"googleapis": "^50.0.0"
}
我的 index.ts
文件中有这个:
import {drive_v3} from "googleapis";
const {Schema$File} = drive_v3.Schema$File
console.log({x:Schema$File})
tsc
告诉我:
error TS2339: Property 'Schema$File' does not exist on type 'typeof drive_v3'.
但是当我查看 .d.ts
文件时,我可以看到是否在那里声明
使用 drive_v3 api 时,导入“Google 驱动器文件”类型的正确方法是什么?
聚会迟到了,但你可以做到这一点
import { drive_v3 } from 'googleapis'
type DriveFile = drive_v3.Schema$File
const file: DriveFile = ....
或者只使用 drive_v3.Schema$File
而不是重新分配它。