Failed Typescript validation error

I’ve successfully added a number of addFormula’s to my code using a combination of reused parameters and local parameters. On my latest formula, I’m getting a “Failed Typescript validation” on my execute statement but I’ve verified all my ParameterType’s are String and all my other POST api calls are also returning: resultType: coda.ValueType.String

Any suggestions would be appreciated

Here is the relevant code:

const usingParameter = coda.makeParameter({

const customerIDParameter = coda.makeParameter({
type: coda.ParameterType.String,
name: “customerid”,
description: “A unique string which all charges from the same customer share.”,
});
const billingEmailParameter = coda.makeParameter({
type: coda.ParameterType.String,
name: “billingEmail”,
description: “The email address of the customer to send an invoice to.”,
});

});

pack.addFormula({
name: “Update_Customer”,
description: “Update customer emails and invoicing type in ChargeDesk”,
resultType: coda.ValueType.String,
isAction: true,

parameters: [
customerIDParameter,
billingEmailParameter,
coda.makeParameter({
type: coda.ParameterType.String,
name: “contactEmail”,
description: “Primary contact email address”
}),
coda.makeParameter({
type: coda.ParameterType.String,
name: “chargeTiming”,
description: “Timing of client invoicing / charging”
}),
],

execute: async function ([customerid, billingEmail, contactEmail, chargeTiming], context) {
let response = await context.fetcher.fetch({
method: “POST”,
url: “https://api.chargedesk.com/v1/customers/” + customerid,
form: {
‘send_email_to’: billingEmail,
‘email’: contactEmail,
‘description’: chargeTiming,
},
});
return response;
},
});

Here is the error message I’m getting:

On line 251 Type ‘([customerid, billingEmail, contactEmail, chargeTiming]: ParamValues<[ParamDefFromOptionsUnion<ParameterType, { type: ParameterType.String; name: string; description: string; }>, ParamDefFromOptionsUnion<ParameterType, { …; }>, ParamDefFromOptionsUnion<…>, ParamDefFromOptionsUnion<…>]>, context: ExecutionConte…’ is not assignable to type ‘({ (params: ParamValues<[ParamDefFromOptionsUnion<ParameterType, { type: ParameterType.String; name: string; description: string; }>, ParamDefFromOptionsUnion<ParameterType, { …; }>, ParamDefFromOptionsUnion<…>, ParamDefFromOptionsUnion<…>]>, context: ExecutionContext): string | Promise<…>; (params: ParamVal…’. Type ‘([customerid, billingEmail, contactEmail, chargeTiming]: ParamValues<[ParamDefFromOptionsUnion<ParameterType, { type: ParameterType.String; name: string; description: string; }>, ParamDefFromOptionsUnion<ParameterType, { …; }>, ParamDefFromOptionsUnion<…>, ParamDefFromOptionsUnion<…>]>, context: ExecutionConte…’ is not assignable to type ‘{ (params: ParamValues<[ParamDefFromOptionsUnion<ParameterType, { type: ParameterType.String; name: string; description: string; }>, ParamDefFromOptionsUnion<ParameterType, { …; }>, ParamDefFromOptionsUnion<…>, ParamDefFromOptionsUnion<…>]>, context: ExecutionContext): string | Promise<…>; (params: ParamValu…’. Type ‘([customerid, billingEmail, contactEmail, chargeTiming]: ParamValues<[ParamDefFromOptionsUnion<ParameterType, { type: ParameterType.String; name: string; description: string; }>, ParamDefFromOptionsUnion<ParameterType, { …; }>, ParamDefFromOptionsUnion<…>, ParamDefFromOptionsUnion<…>]>, context: ExecutionConte…’ is not assignable to type ‘{ (params: ParamValues<[ParamDefFromOptionsUnion<ParameterType, { type: ParameterType.String; name: string; description: string; }>, ParamDefFromOptionsUnion<ParameterType, { …; }>, ParamDefFromOptionsUnion<…>, ParamDefFromOptionsUnion<…>]>, context: ExecutionContext): string | Promise<…>; (params: ParamValu…’. Type ‘Promise<FetchResponse>’ is not assignable to type ‘string | Promise’. Type ‘Promise<FetchResponse>’ is not assignable to type ‘Promise’. Type ‘FetchResponse’ is not assignable to type ‘string’.

Solved the problem (thought don’t fully understand why it created this issue). It had something to do with the resultType. I ended up pulling out all the response code since this is just an update push, and changing my return to:

return “Done”;

Now that I have it at least building, I can go back and play with it later to try to figure it out.

It looks like you tried returning response which is a Promise.

Look at this example, they use return response.body.url;

It looks like @Ron_Gerrans3 was using await, so response would have been a FetchResponse, not a Promise. However a FetchResponse is not a string, and the execute function must return a string when you set resultType: coda.ValueType.String.

1 Like

Thanks for the follow-up, still working through all of this