问题描述
有人知道用于node.js(或浏览器)的google Calendar API(npm googleapis pkg)是否具有可用于打字稿的类型。
允许在节点或角度中使用强类型方法。
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 TypescriptBUT, when I try, as stated in the doc
import { google, calendar_v3 } from 'googleapis';
打字稿告诉我:
[ts] Module' / 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,它指向所有API所在的../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.
Philippe
推荐答案
您绝对可以将此库与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-打字稿类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!