Deploy Friday: hot topics for cloud technologists and developers

#21: Javascript News: TypeScript 4.0 and More

May 06, 2021 Stefan Adolf, Sarah Dayan, Robert Douglass Season 1 Episode 21
Deploy Friday: hot topics for cloud technologists and developers
#21: Javascript News: TypeScript 4.0 and More
Chapters
Deploy Friday: hot topics for cloud technologists and developers
#21: Javascript News: TypeScript 4.0 and More
May 06, 2021 Season 1 Episode 21
Stefan Adolf, Sarah Dayan, Robert Douglass

What’s new with Typescript 4.0 

Typescript is an Object-oriented, open source, scripting language, with static typing. With our guests, we discuss several exciting updates that come with the release of Typescript 4.0 , such as short-circuiting assignment operators, labeled tuple elements, and more. You can also follow along with this helpful slideshow about the release.

Variadic tuple types

Variadic tuple types are of value when you don’t know the ordering of an array. Our guest Stefan Adolf, Developer Ambassador, says, “Variadic tuple types allow you to say the first three elements are of type string, and the last three elements will be of type number.” He explains further, “These little arrest operators allow you to spread arrays, so you can de-structure arrays or classes by using these three little dots. You can put them as type pins in parameters and return values. So you can be very sure that what you are hinting towards is actually typed the way you declared it.”

Class property type inference from constructors

Normally, when you’ve got properties of a class, such as length, width, and area, you would give those types. But in TypeScript 4.0, this new inference feature allows you to skip giving properties a type, and it will infer the type by whatever you say the constructor is supposed to take. 

According to Stefan and Sarah, this feature can help developers save time and improve readability. Sarah Dayan, a Software Engineer at Algolia, explains further, “Type inference is very important, especially in TypeScript. You don’t actually want to clutter your JavaScript code with types, you want to infer as much as possible. The goal is not for you to define a type for everything, but to type what cannot be guessed by the program, and then let the logic of TypeScript decide, ‘Okay, you have a violation here or there.’ So inference is actually really interesting, because TypeScript is supposed to take the minimal amount of typing, and be smarter than you. Not having to repeat types makes a lot of sense.”

Try Next.js on Platform.sh today

Platform.sh
Learn more about us.
Get started with a free trial.
Have a question? Get in touch!

Platform.sh on social media
Twitter @platformsh
Twitter (France): @platformsh_fr
LinkedIn: Platform.sh
LinkedIn (France): Platform.sh
Facebook: Platform.sh

Watch, listen, and subscribe to the Platform.sh Deploy Friday podcast:
YouTube
Apple Podcasts
Buzzsprout

Platform.sh is a robust, reliable hosting platform that gives development teams the tools to build and scale applications efficiently. Whether you run one or one thousand websites, you can focus on creating features and functionality with your favorite tech stack and leave managing infrastructure and processes to us.

Show Notes

What’s new with Typescript 4.0 

Typescript is an Object-oriented, open source, scripting language, with static typing. With our guests, we discuss several exciting updates that come with the release of Typescript 4.0 , such as short-circuiting assignment operators, labeled tuple elements, and more. You can also follow along with this helpful slideshow about the release.

Variadic tuple types

Variadic tuple types are of value when you don’t know the ordering of an array. Our guest Stefan Adolf, Developer Ambassador, says, “Variadic tuple types allow you to say the first three elements are of type string, and the last three elements will be of type number.” He explains further, “These little arrest operators allow you to spread arrays, so you can de-structure arrays or classes by using these three little dots. You can put them as type pins in parameters and return values. So you can be very sure that what you are hinting towards is actually typed the way you declared it.”

Class property type inference from constructors

Normally, when you’ve got properties of a class, such as length, width, and area, you would give those types. But in TypeScript 4.0, this new inference feature allows you to skip giving properties a type, and it will infer the type by whatever you say the constructor is supposed to take. 

According to Stefan and Sarah, this feature can help developers save time and improve readability. Sarah Dayan, a Software Engineer at Algolia, explains further, “Type inference is very important, especially in TypeScript. You don’t actually want to clutter your JavaScript code with types, you want to infer as much as possible. The goal is not for you to define a type for everything, but to type what cannot be guessed by the program, and then let the logic of TypeScript decide, ‘Okay, you have a violation here or there.’ So inference is actually really interesting, because TypeScript is supposed to take the minimal amount of typing, and be smarter than you. Not having to repeat types makes a lot of sense.”

Try Next.js on Platform.sh today

Platform.sh
Learn more about us.
Get started with a free trial.
Have a question? Get in touch!

Platform.sh on social media
Twitter @platformsh
Twitter (France): @platformsh_fr
LinkedIn: Platform.sh
LinkedIn (France): Platform.sh
Facebook: Platform.sh

Watch, listen, and subscribe to the Platform.sh Deploy Friday podcast:
YouTube
Apple Podcasts
Buzzsprout

Platform.sh is a robust, reliable hosting platform that gives development teams the tools to build and scale applications efficiently. Whether you run one or one thousand websites, you can focus on creating features and functionality with your favorite tech stack and leave managing infrastructure and processes to us.