- Newest
- Most votes
- Most comments
CloudFront Functions only support a restricted subset of JavaScript. TypeScript is not natively supported for CloudFront Functions. You can write your function in TypeScript and then transpile it down to JavaScript, but you have to ensure that the generated JavaScript code adheres to the limitations imposed by CloudFront Functions.
AWS CDK does support CloudFront Functions, but the CDK constructs for CloudFront Functions expect the function code to be a simple string containing the JavaScript code or a path to a .js file.
To use TypeScript for this, you could:
- Write your function logic in TypeScript.
- Transpile it to JavaScript.
- Make sure the generated JavaScript adheres to CloudFront Function's limitations.
- Use the JavaScript code as the code parameter for your EdgeFunction in CDK.
I think I'm going to answer my own question and reflect upon the limitations of a Javascript that runs as a Cloudfront Function and all the associated limitations. Based on that, what I asked doesn't make a whole lot of sense. The code is small, I just preferred it be fully typed. I decided to live without.
Relevant content
- asked a year ago
- AWS OFFICIALUpdated 4 years ago
- AWS OFFICIALUpdated 7 months ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 6 months ago
This is exactly what I'm trying to do, as I'm not incredibly great with javascript and the strong typing that comes with TypeScript helps me avoid all sorts of problems.