pulumi / pulumi-gcp

A Google Cloud Platform (GCP) Pulumi resource package, providing multi-language access to GCP
Apache License 2.0
182 stars 52 forks source link

HttpCallbackFunction typings don't work #939

Open cnunciato opened 1 year ago

cnunciato commented 1 year ago

On a new gcp-typescript project (or even a new typescript project with @pulumi/gcp added afterward), the HttpCallbackFunction resource doesn't compile -- at least not when it references req.body or res.send():

import * as pulumi from "@pulumi/pulumi";
import * as gcp from "@pulumi/gcp";

new gcp.cloudfunctions.HttpCallbackFunction("callback", (req, res) => {
    res.send("Hi, world!");
});

The typings suggest this should work, however:

image

Noticed this while investigating https://github.com/pulumi/examples/issues/1294. Changing the typing of req and res in these examples to :any both compiles and works as expected when deployed, so perhaps the wrong typing is getting picked up somehow during function serialization? Not sure where the error is, but there does seem to be something going wrong somehow.

viveklak commented 1 year ago

Do you have a sense of when this started to break? The typing here hasn't changed in 2 years. The callback is expected to be of this type: https://github.com/pulumi/pulumi-gcp/blame/master/sdk/nodejs/cloudfunctions/zMixins.ts#L415

cnunciato commented 1 year ago

I do not. Only that it was reported recently.