What are your experiences with using TypeScript vs...
# typescript
r
What are your experiences with using TypeScript vs plain JS? (with Pulumi of course) I honestly don’t like introducing TypeScript into projects - adds to much bloat and maintenance overhead, and it doesn’t provide any runtime type safety. In my previous projects I didn’t feel that the PROs outweigh the CONs. Also, I want my Serverless Functions to be as lean as possible, and I want the code to be as simple as it can get. I know that the author of Pulumi might have a personal bias towards TypeScript because he helped design it, but I’m not sure if that puts regular JavaScript in a disadvantage here. Thanks 👍
m
TypeScript has been a wonderful experience for our team. We catch code issues earlier, even if it's not doing runtime typing, the transplied javascript is more reliable than just javascript, even if you have 100% test coverage.
3
m
typescript works well when you have defined interface types, especially for external APIs
really easy to use crosswalk to set up lambda apis that talk to popular services (like Github, which has types for it's API)
2
tbh ts doesn't create a lot of bloat here because you don't have to worry about JSX, webpack, etc, pretty much everything works out of box w/ a default tsconfig
2
m
Pulumi provides its own interpreter for typescript, so you don't need to install typescript as a dependencies. You can continue to write your applications in javascript, but you're missing out.
1
l
Also typescript in Pulumi does not imply typescript in the lambdas that Pulumi deploys. Separate code.
r
@little-cartoon-10569 Ahhh that’s a good one! Do you have any links that explain how this can be achieved? Thanks 🙂
m
The Pulumi
index.ts
declares your resources, and with some magic functions, it can also package up your apps to deploy to those resources. Your build process doesn't have to be coupled with Pulumi, or even exist. Javascript doesn't need to be "built" assuming you don't have dependencies, but even if you did, it's about telling the Pulumi plan where your artifacts that get deployed to your resources are. Examples: • https://github.com/pulumi/examples/tree/master/aws-ts-lambda-thumbnailer (js in a docker runtime for lambda) • https://github.com/pulumi/examples/tree/master/aws-ts-voting-app (python app to ecs) • https://github.com/pulumi/examples/blob/master/aws-ts-apigateway/index.ts#L23-L49 (js in lambda via Pulumi magic)