Why does this compile cleanly in TypeScript, but crash when called with no arguements? Go!

Estimated read time 1 min read

Post Contenthttps://www.youtube.com/shorts/bAjHqVjRj8I

​ Here’s a TypeScript developer challenge that shows how optional parameters can get tricky. TypeScript accepts the code without errors. But the moment you call the function with no arguments, it blows up at runtime. Why does this compile cleanly, and what change would you make so the bug is caught during type checking instead of in production? Share your solution in the comments.

Subscribe to Google for Developers → https://goo.gle/developers

Speakers: Meg Bauman   Read More Google for Developers 

You May Also Like

More From Author