Skip to content
This repository was archived by the owner on Oct 23, 2023. It is now read-only.

Conversation

@techiejd
Copy link

This is necessary to access Platforms in a .ts file.

For example:
new Payload(Platforms.UNSPECIFIED,
payload, {rawPayload: true, sendAsMessage: true})

The platforms are not exposed any where publicly. From the js examples I've seen online, most people access the platforms by WebhookClient.Platform. This doesn't work with ts because WebhookClient.Platform is not an explicit method or a field.

The @types/dialogflow-fulfillment exports the platforms.

Without exposing it, we get a run time error because the dialogflow-fulfillment.d.ts is not compiled and the .js does not expose the platforms. So, the solution is to also export it from the .js .

This is necessary to access Platforms in a .ts file.

For example:
new Payload(Platforms.UNSPECIFIED,
            payload, {rawPayload: true, sendAsMessage: true})

The platforms are not exposed any where publicly. From the js examples I've seen online, most people access the platforms by WebhookClient.Platform. This doesn't work with ts because WebhookClient.Platform is not an explicit method or a field.

The @types/dialogflow-fulfillment exports the platforms; see https://github.com/DefinitelyTyped/DefinitelyTyped/blob/f7ec78508c6797e42f87a4390735bc2c650a1bfd/types/dialogflow-fulfillment/index.d.ts#L13 . With that said, it breaks in run time because the .ts is not compiled and the .js does not expose the platforms.

Without exposing it, we have the same situation explained here: https://lukasbehal.com/2017-05-22-enums-in-declaration-files/ . See microsoft/TypeScript#37120 (comment)  for explanation on this solution.
@google-cla
Copy link

google-cla bot commented Aug 19, 2022

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant