谷歌日历 API - 打字稿类型 [英] google Calendar API - typescript types

查看:33
本文介绍了谷歌日历 API - 打字稿类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道 node.js(或浏览器)的 google Calendar API (npm googleapis pkg) 是否有可用于打字稿的类型.允许在 node 或 angular 中采用强类型方法.

Does anybody know if the google Calendar API (npm googleapis pkg) for node.js (or browser) has types available that could be used in typescript. Allowing a strongly typed approach in node or angular.

我找不到@types/googleapis npm 包.文档中也没有任何内容.

I could not find a @types/googleapis npm package. Nor anything in the doc.

欢迎提供任何建议.

提前致谢.

--文档说它是本地支持的,不需要单独的包.文档 - 部分打字稿但是,当我尝试时,如文档中所述

-- The documentation says it is natively supported, no need for separate package. Doc - section Typescript BUT, when I try, as stated in the doc

    import { google, calendar_v3 } from 'googleapis';

打字稿告诉我:[ts] 模块 '"/home/me/myProject/functions/node_modules/googleapis/build/src/index"' 没有导出成员 'calendar_v3'.[2305]

Typescript tells me : [ts] Module '"/home/me/myProject/functions/node_modules/googleapis/build/src/index"' has no exported member 'calendar_v3'. [2305]

当我查看 googleapis/build/src/index.d.ts 时,我看到 GoogleApis,它指向所有 apis 所在的 ../apis,带有一个包含命名空间的 v3.d.ts 文件

When I look in googleapis/build/src/index.d.ts I see GoogleApis, that point to ../apis where all the apis are, with a v3.d.ts file including the namespace

    * @namespace calendar
    * @type {Function}
    * @version v3
    * @variation v3

所以,很明显,它在那里,但我遗漏了一些东西......但是什么?你如何在打字稿中使用这个库?欢迎举个例子.

So, obviously, it is there, but I am missing something ... but what? How can you use this library in typescript? An example would be welcome.

菲利普

推荐答案

您绝对可以将此库与 TypeScript 一起使用.它是用 TypeScript 编写的!这是一个基本示例:

You can absolutely use this library with TypeScript. It's written in TypeScript! Here's a basic example:

import {google} from 'googleapis';
const calendar = google.calendar('v3');

这是获取对 API 特定子部分的引用的正确方法:)

That's the right way to get a reference to a particular subsection of the API :)

希望这会有所帮助!

这篇关于谷歌日历 API - 打字稿类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆