TypeScript "satisfies" keyword breaks build

I have a TypeScript function that’s being built using netlify-cli. When I use the “satisfies” keyword, the build breaks with the following error:

[ERROR] Expected “;” but found “satisfies”

export const handler = (async ({ body, headers }) => {
  // function body here
}) satisfies Handler;

Is there a specific reason you’re using satisfies? If I remember correctly this keyword does not exist in the TypeScript language. so I’m pretty sure this is why your build breaks.

Once you fix your code make sure you update your netlify.toml and indicate the location of your typescript function then run the build process before you deploy.

I hope this helps. I’m also attaching our build debugging resource. Which should help with your debugging process.

Thanks for the reply! The satisfies operator has been supported since TypeScript 4.9: https://www.typescriptlang.org/docs/handbook/release-notes/typescript-4-9.html - in my workspace I’m using TypeScript 5.1.

I use netlify-cli to build my functions (so netlify dev) and everything else works - it’s only when I introduce the satisfies operator that the build stops working. Does @netlify/build roll its own TS compilation? Are there any dependencies I can try bumping? I’ve already ensured all the @netlify/* and netlify-cli are pinned to the latest versions.

That was introduced in esbuild 0.15.3: esbuild/CHANGELOG-2022.md at main · evanw/esbuild (github.com)

You might find this thread relevant: @netlify/esbuild hasn't seen a new release in 10 months, which is causing newer TypeScript code to fail to build