Dialogflow-fulfillment-nodejs: Types for TypeScript development

Created on 9 Aug 2018  路  17Comments  路  Source: dialogflow/dialogflow-fulfillment-nodejs

A very very useful enhancement would be a d.ts file for those of us programming in Typescript, not in "plain" JS.

Feature Request

Most helpful comment

Extended @diegodalbosco 's gist with documentation and fields here https://gist.github.com/slowtick/b6164491ce47d0c5c4aa51c5fbe5e7fd

All 17 comments

I was not expecting this

```javascript
npm install @types/dialogflow-fulfillment --save
npm ERR! code E404
npm ERR! 404 Not Found: @types/dialogflow-fulfillment@latest

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\cypherOS\AppData\Roaming\npm-cache_logs\2018-09-08T16_50_07_880Z-debug.log```

any update?

This needs to be implemented. Would be super useful!

Gimme, please.

I made a very basic one. There is propably wrong stuff in there as I did not test everything and as this is my first defintion file there is propably stuff that should have been done in other ways. I will extend it while working with the lib. So it might miss stuff currently.

https://gist.github.com/MTRNord/070e8de92f18841ab50e6533f377d7ba

(A official one or atleast one hosted at @types/ would be obviously a lot better)

+1

+1

Never going back to vanilla JS ever again. How do I use your definition file @MTRNord ? I tried adding a reference to it but still no intellisense:

/// <reference path="./dialogflow-fulfillment.d.ts" />
const { WebhookClient } = require('dialogflow-fulfillment');

@neil-119 I do have "typeRoots": ["node_modules/@types", "src/types"] in my "tsconfig.json" and have that file in src/types

I made a very basic one. There is propably wrong stuff in there as I did not test everything and as this is my first defintion file there is propably stuff that should have been done in other ways. I will extend it while working with the lib. So it might miss stuff currently.

https://gist.github.com/MTRNord/070e8de92f18841ab50e6533f377d7ba

(A official one or atleast one hosted at @types/ would be obviously a lot better)

Thanks for sharing your definitions, you saved me. I found a problem in the Payload class constructor: according to documentation sendAsMessage and rawPayload are not simple parameters but they're inside a third parameter as object like this

options?: { sendAsMessage?: boolean, rawPayload?: boolean }

I forked your gist here with the fix: https://gist.github.com/diegodalbosco/6e1b7218d5c48925fd8a59538e5a6640

Why don't you guys create a PR for type definitions in "@types/"-related repository - https://github.com/DefinitelyTyped/DefinitelyTyped?
gist is nice, but otherwise you could be even more useful contributing to the project, so many other people can benefit from it, having types available in "@types/" namespace.
Thoughts?

@rodush I simply didn't because I don't have enough knowledge on typings :) Otherwise I would have maybe

@rodush @MTRNord I think these types aren't ready to be officially published, they're partial and I personally haven't tested so I'm not sure it they're good or not. I would like to find the time to review them and check the official documentation. Also, some feedback about types would be great :)

+1

Anyone interested in submitting the current types? Otherwise I might put up a PR.

Edit: Some libraries are adopting the practice of including a index.d.ts file in the NPM package. I think this is better than maintaining 2 different modules.

Extended @diegodalbosco 's gist with documentation and fields here https://gist.github.com/slowtick/b6164491ce47d0c5c4aa51c5fbe5e7fd

@slowtick That gist is pretty helpful! Thanks for sharing.

@slowtick I've updated your gist with the deprecations of getContext/setContext methods in favor of context.get/context.set

https://gist.github.com/diegodalbosco/3ac6551e1b4ffe7f2896866e6b56fcc3

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sarupbanskota picture sarupbanskota  路  3Comments

malikasinger1 picture malikasinger1  路  4Comments

harmnot picture harmnot  路  5Comments

kwizfreak picture kwizfreak  路  9Comments

jzxhuang picture jzxhuang  路  6Comments