dialogflow-fulfillment-nodejs icon indicating copy to clipboard operation
dialogflow-fulfillment-nodejs copied to clipboard

Types for TypeScript development

Open Flocksserver opened this issue 6 years ago • 17 comments

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

Flocksserver avatar Aug 09 '18 15:08 Flocksserver

I was not expecting this

 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```

mInzamamMalik avatar Sep 08 '18 16:09 mInzamamMalik

any update?

mInzamamMalik avatar Oct 17 '18 14:10 mInzamamMalik

This needs to be implemented. Would be super useful!

AskYous avatar Dec 11 '18 19:12 AskYous

Gimme, please.

nicktobolski avatar Jan 17 '19 14:01 nicktobolski

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)

MTRNord avatar Jan 19 '19 17:01 MTRNord

+1

fnfilho avatar Jan 27 '19 12:01 fnfilho

+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 avatar Feb 19 '19 17:02 neil-119

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

MTRNord avatar Feb 19 '19 17:02 MTRNord

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

diegodalbosco avatar Apr 04 '19 14:04 diegodalbosco

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 avatar Apr 15 '19 15:04 rodush

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

MTRNord avatar Apr 15 '19 18:04 MTRNord

@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 :)

diegodalbosco avatar Apr 16 '19 07:04 diegodalbosco

+1

JNLConsulting avatar Jun 12 '19 17:06 JNLConsulting

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.

jotatoledo avatar Jul 31 '19 16:07 jotatoledo

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

slowtick avatar Aug 02 '19 09:08 slowtick

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

hcharley avatar Aug 07 '19 22:08 hcharley

@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

diegodalbosco avatar Mar 20 '20 10:03 diegodalbosco