# What's coming in TypeScript 4?

DevFeed: [What's coming in TypeScript 4?](<https://devfeed.tech/articles/what-s-coming-in-typescript-4-19103.md>)

Original publisher: [Read original article](<https://httptoolkit.com/blog/whats-coming-in-typescript-4/>)

Author: HTTP Toolkit; Tim Perry

Published: 2020-06-22T16:00:00Z

Content type: tutorial

Language: en

Sources: [HTTP Toolkit](<https://devfeed.tech/sources/http-toolkit.md>)

Topics: [TypeScript](<https://devfeed.tech/topics/typescript.md>), [Code](<https://devfeed.tech/topics/code.md>), [Development](<https://devfeed.tech/topics/development.md>)

Tags: [arrays](<https://devfeed.tech/tags/arrays.md>), [code](<https://devfeed.tech/tags/code.md>), [development](<https://devfeed.tech/tags/development.md>), [function](<https://devfeed.tech/tags/function.md>), [generic](<https://devfeed.tech/tags/generic.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [patterns](<https://devfeed.tech/tags/patterns.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

## AI overview

An overview of planned TypeScript 4 additions, focusing on variadic tuple types. The article explains how these types can preserve more precise information when typing functions that accept and combine tuple arguments, including concatenation and flexible rest parameters.

## Source excerpt

TypeScript 4 is coming up fast: a first beta release is planned for this week (June 25th), with the final release aiming for mid-August. It's important to note that TypeScript does not follow semver, so 4.0 is not as big a deal as it sounds! There can be (and often are) breaking changes between any minor TypeScript versions, and major version bumps like this happen primarily for marketing reasons, not technical ones. This bump to 4.0 doesn't suggest that everything is going to break, and this won't be a huge world-changing release, but it does bring some nice additions, particularly on the typing side. For projects like HTTP Toolkit (written entirely in TypeScript) that means faster development & fewer bugs! Let's dive into the details: Variadic tuple types Also known as 'variadic kinds', this is a complex but substantial new feature for TypeScript's type system. ~~It's not 100% confirmed yet (the PR remains unmerged!), but it's explicitly in the 4.0 roadmap, and Anders Hejlsberg himself has called it out as planned for the coming release.~~ Update: PR now merged, looks like this is happening! Explaining this is complicated if you don't have an strong existing grasp of type theory, but it's easy to demo. Let's try to type a concat function with tuple arguments: function concat( nums: number[], strs: string[] ): (string | number)[] { return [...nums, ...strs]; } let vals = concat([1, 2], ["hi"]); let val = vals[1]; // infers string | number, but we *know* it's a number (2) // TS does support accurate types for these values though: let typedVals = concat([1, 2], ["hi"]) as [number, number, string]; let typedVal = typedVals[1] // => infers number, correctly This is valid TypeScript code today, but it's suboptimal. Here, concat works OK, but we're losing information in the types and we have to manually fix that later if we want to get accurate values elsewhere. Right now it's impossible to fully type such a function to avoid this. With variadic types though, we can: fun