Open berkzorlu opened 11 months ago
Within the AppSync JS runtime environment, I have encountered an unexpected error.
If all of the following are met:
The deployment results in an error.
My tsconfig settings are identical to the ones recommended on https://docs.aws.amazon.com/appsync/latest/devguide/resolver-reference-overview-js.html#working-with-typescript but the transpiled js is still troublesome to the js runtime.
export type Params = { required: string; optional?: string; }; export const foo = ({ required, optional }: Params): void => { util.appendError(`${required}${optional}`, 'log'); };
And we call this function without providing the optional property:
foo({ required: 'bar' });
The transpiled js file looks like this:
// src/test.ts var foo = ({ required, optional }) => { util.appendError(`${required}${optional}`, "log"); }; export { foo };
This results in a deployment error every time.
The error goes away if we destructure inside the function rather than the function signature:
export type Params = { required: string; optional?: string; }; export const foo = (params: Params): void => { const { required, optional } = params; util.appendError(`${required}${optional}`, 'log'); };
Is this expected behavior?
Within the AppSync JS runtime environment, I have encountered an unexpected error.
If all of the following are met:
The deployment results in an error.
My tsconfig settings are identical to the ones recommended on https://docs.aws.amazon.com/appsync/latest/devguide/resolver-reference-overview-js.html#working-with-typescript but the transpiled js is still troublesome to the js runtime.
Steps to Reproduce
And we call this function without providing the optional property:
The transpiled js file looks like this:
This results in a deployment error every time.
Workaround
The error goes away if we destructure inside the function rather than the function signature:
Is this expected behavior?