typescript - @types/dialogflow 包说 "dialogflow provides its own type definitions"但似乎不是

标签 typescript npm dialogflow-es

我正在使用 dialogflow npm 包,不同于actions-on-googlegoogleapis包。

dialogflow 包没有自己的类型定义。因此,我一直在使用@types/dialogflow打包在一起。

最近,类型定义包(@types/dialogflow)更新自v0.11.0v4.0.4 ,这是现在的最新版本,包装上写着

This is a stub types definition. dialogflow provides its own type definitions, so you do not need this installed.

但是dialogflow npm包好像没有给出类型定义。 TS 编译器一直说

Could not find a declaration file for module 'dialogflow'. '....js' implicitly has an 'any' type. Try npm install @types/dialogflow if it exists or add a new declaration (.d.ts) file containing declare module 'dialogflow';ts(7016)

这个类型定义包有什么问题?

最佳答案

据我所知,dialogflow 尚未发布其类型。没有问题,它们甚至没有列在 this ticket 上。跟踪谷歌 API 类型定义。 (引用自here)

This PR已弃用的 @types/dialogflow 没有添加任何相关链接以表明它们是 native 包​​含的。

同时,我会在你的 json 包中添加固定版本的 @types/dialogflow

npm install @types/dialogflow@0.11.0

该版本似乎是弃用前的最后一个版本

更新

另一个选项 according to this PR就是尝试这样导入

import * as dialogflow from "dialogflow/protos/protos"

并验证 dialogflow 上的类型 - 也许您可能需要做一些返工

关于typescript - @types/dialogflow 包说 "dialogflow provides its own type definitions"但似乎不是,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59366832/

相关文章:

javascript - TypeScript/JavaScript 中的 array.indexOf

ubuntu - 无法使用 npm 安装 history.js

google-cloud-functions - DialogFlow 测试 Cloud Function 并发性

node.js - 在我的在线服务器上部署我的Messenger chatBot

typescript - yield all 中的 Redux saga typescript 类型错误

typescript - 如何修复 "property destructuring pattern expected"错误?

typescript - 类型错误 : undefined is not an object (evaluating 'this._callListeners.bind' )

reactjs - 模块构建失败: ReferenceError: [BABEL]

javascript - 如何正确修复 npm ERR!来 self 路径上 Ubuntu 的权限

python - 如何将我的 DialogFlow 聊天机器人与 python 联机?