{"id":5106,"date":"2026-03-23T08:34:10","date_gmt":"2026-03-23T16:34:10","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/typescript\/?p=5106"},"modified":"2026-03-23T09:23:48","modified_gmt":"2026-03-23T17:23:48","slug":"announcing-typescript-6-0","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-6-0\/","title":{"rendered":"Announcing TypeScript 6.0"},"content":{"rendered":"<p>Today we are excited to announce the availability of TypeScript 6.0!<\/p>\n<p>If you are not familiar with TypeScript, it&#8217;s a language that builds on JavaScript by adding syntax for types, which enables type-checking to catch errors, and provide rich editor tooling.\nYou can learn more about TypeScript and how to get started on the <a href=\"https:\/\/www.typescriptlang.org\/\">TypeScript website<\/a>.<\/p>\n<p>But if you&#8217;re already familiar with the language, you can get TypeScript 6.0 through npm with the following command:<\/p>\n<pre class=\"prettyprint language-sh\" style=\"padding: 10px;border-radius: 10px;\"><code>npm install -D typescript\r\n<\/code><\/pre>\n<p>TypeScript 6.0 is a unique release in that we intend for it to be the last release based on the current JavaScript codebase.\n<a href=\"https:\/\/devblogs.microsoft.com\/typescript\/typescript-native-port\/\">As announced last year<\/a> (with <a href=\"https:\/\/devblogs.microsoft.com\/typescript\/progress-on-typescript-7-december-2025\/\">recent updates here<\/a>), we are working on a new codebase for the TypeScript compiler and language service written in Go that takes advantage of the speed of native code and shared-memory multi-threading.\nThat new codebase will be the foundation of TypeScript 7.0 and beyond.<\/p>\n<p>TypeScript 6.0 acts as the bridge between TypeScript 5.9 and 7.0.\nAs such, most changes in TypeScript 6.0 are meant to help align and prepare for adopting TypeScript 7.0.\nIt may seem surprising to say, but TypeScript 7.0 <strong>is actually extremely close to completion<\/strong>.\nYou can <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=TypeScriptTeam.native-preview\">try it out in Visual Studio Code<\/a> or <a href=\"https:\/\/npmx.dev\/package\/@typescript\/native-preview\">install it from npm<\/a>.\nIn fact, if you&#8217;re able to adopt TypeScript 6.0, we encourage you to try out the native previews of TypeScript 7.0.<\/p>\n<p>With that said, there are some new features and improvements in TypeScript 6.0s that are not just about alignment.\nLet&#8217;s take a look at some of the highlights of this release, followed by a more detailed look at what&#8217;s changing for 7.0 and how to prepare for it.<\/p>\n<h2 id=\"whats-new-since-the-beta-and-rc\">What&#8217;s New Since the Beta and RC?<\/h2>\n<p>Since TypeScript 6.0 beta, we have made a few noteworthy changes &#8211; mostly to align with the behavior of TypeScript 7.0.<\/p>\n<p>One adjustment is in type-checking for function expressions in generic calls, especially those occurring in generic JSX expressions (<a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63163\">see this pull request<\/a>).\nThis will typically catch more bugs in existing code, though you may find that some generic calls may need an explicit type argument.<\/p>\n<p>We have also extended our deprecation of import assertion syntax (i.e. <code>import ... assert {...}<\/code>) <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63172\">to <code>import()<\/code> calls<\/a> like <code>import(..., { assert: {...}})<\/code><\/p>\n<p>Finally, we have updated the DOM types to reflect the latest web standards, including some adjustments to the Temporal APIs as well.<\/p>\n<h2 id=\"less-context-sensitivity-on-this-less-functions\">Less Context-Sensitivity on <code>this<\/code>-less Functions<\/h2>\n<p>When parameters don&#8217;t have explicit types written out, TypeScript can usually infer them based on an expected type, or even through other arguments in the same function call.<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>declare function callIt&lt;T&gt;(obj: {\r\n    produce: (x: number) =&gt; T,\r\n    consume: (y: T) =&gt; void,\r\n}): void;\r\n\r\n\/\/ Works, no issues.\r\ncallIt({\r\n    produce: (x: number) =&gt; x * 2,\r\n    consume: y =&gt; y.toFixed(),\r\n});\r\n\r\n\/\/ Works, no issues even though the order of the properties is flipped.\r\ncallIt({\r\n    consume: y =&gt; y.toFixed(),\r\n    produce: (x: number) =&gt; x * 2,\r\n});\r\n<\/code><\/pre>\n<p>Here, TypeScript can infer the type of <code>y<\/code> in the <code>consume<\/code> function based on the inferred <code>T<\/code> from the <code>produce<\/code> function, regardless of the order of the properties.\nBut what about if these functions were written using <em>method syntax<\/em> instead of arrow function syntax?<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>declare function callIt&lt;T&gt;(obj: {\r\n    produce: (x: number) =&gt; T,\r\n    consume: (y: T) =&gt; void,\r\n}): void;\r\n\r\n\/\/ Works fine, `x` is inferred to be a number.\r\ncallIt({\r\n    produce(x: number) { return x * 2; },\r\n    consume(y) { return y.toFixed(); },\r\n});\r\n\r\ncallIt({\r\n    consume(y) { return y.toFixed(); },\r\n    \/\/                  ~\r\n    \/\/ error: 'y' is of type 'unknown'.\r\n\r\n    produce(x: number) { return x * 2; },\r\n});\r\n<\/code><\/pre>\n<p>Strangely enough, the second call to <code>callIt<\/code> results in an error because TypeScript is not able to infer the type of <code>y<\/code> in the <code>consume<\/code> method.\nWhat&#8217;s happening here is that when TypeScript is trying to find candidates for <code>T<\/code>, it will first skip over functions whose parameters don&#8217;t have explicit types.\nIt does this because certain functions may need the inferred type of <code>T<\/code> to be correctly checked &#8211; in our case, we need to know the type of <code>T<\/code> to analyze our <code>consume<\/code> function.<\/p>\n<p>These functions are called <em>contextually sensitive functions<\/em> &#8211; basically, functions that have parameters without explicit types.\nEventually the type system will need to figure out types for these parameters &#8211; but this is a bit at odds with how inference works in generic functions because the two &quot;pull&quot; on types in different directions.<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>function callFunc&lt;T&gt;(callback: (x: T) =&gt; void, value: T) {\r\n    return callback(value);\r\n}\r\n\r\ncallFunc(x =&gt; x.toFixed(), 42);\r\n\/\/       ^\r\n\/\/ We need to figure out the type of `x` here,\r\n\/\/ but we also need to figure out the type of `T` to check the callback.\r\n<\/code><\/pre>\n<p>To solve this, TypeScript skips over contextually sensitive functions during type argument inference, and instead checks and infers from other arguments first.\nIf skipping over contextually sensitive functions doesn&#8217;t work, inference just continues across any unchecked arguments, going left-to-right in the argument list.\nIn the example immediately above, TypeScript will skip over the callback during inference for <code>T<\/code>, but will then look at the second argument, <code>42<\/code>, and infer that <code>T<\/code> is <code>number<\/code>.\nThen, when it comes back to check the callback, it will have a contextual type of <code>(x: number) =&gt; void<\/code>, which allows it to infer that <code>x<\/code> is a <code>number<\/code> as well.<\/p>\n<p>So what&#8217;s going on in our earlier examples?<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ Arrow syntax - no errors.\r\ncallIt({\r\n    consume: y =&gt; y.toFixed(),\r\n    produce: (x: number) =&gt; x * 2,\r\n});\r\n\r\n\/\/ Method syntax - errors!\r\ncallIt({\r\n    consume(y) { return y.toFixed(); },\r\n    \/\/                  ~\r\n    \/\/ error: 'y' is of type 'unknown'.\r\n\r\n    produce(x: number) { return x * 2; },\r\n});\r\n<\/code><\/pre>\n<p>In both examples, <code>produce<\/code> is assigned a function with an explicitly-typed <code>x<\/code> parameter.\nShouldn&#8217;t they be checked identically?<\/p>\n<p>The issue is subtle: most functions (like the ones using method syntax) have an implicit <code>this<\/code> parameter, but arrow functions do not.\nAny usage of <code>this<\/code> could require &quot;pulling&quot; on the type of <code>T<\/code> &#8211; for example, knowing the type of the containing object literal could in turn require the type of <code>consume<\/code>, which uses <code>T<\/code>.<\/p>\n<p>But we&#8217;re not using <code>this<\/code>!\nSure, the function might have a <code>this<\/code> value at runtime, but it&#8217;s never used!<\/p>\n<p>TypeScript 6.0 takes this into account when it decides if a function is contextually sensitive or not.\nIf <code>this<\/code> is never actually <em>used<\/em> in a function, then it is not considered contextually sensitive.\nThat means these functions will be seen as higher-priority when it comes to type inference, and all of our examples above now work!<\/p>\n<p><a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62243\">This change was provided<\/a> thanks to the work of <a href=\"https:\/\/github.com\/Andarist\">Mateusz Burzy\u0144ski<\/a>.<\/p>\n<h2 id=\"subpath-imports-starting-with\">Subpath Imports Starting with <code>#\/<\/code><\/h2>\n<p>When Node.js added support for modules, it added a feature called <a href=\"https:\/\/nodejs.org\/api\/packages.html#subpath-imports\">&quot;subpath imports&quot;<\/a>.\nThis is basically <a href=\"https:\/\/nodejs.org\/api\/packages.html#imports\">a field called <code>imports<\/code><\/a> which allows packages to create internal aliases for modules within their package.<\/p>\n<pre class=\"prettyprint language-json\" style=\"padding: 10px;border-radius: 10px;\"><code>{\r\n    &quot;name&quot;: &quot;my-package&quot;,\r\n    &quot;type&quot;: &quot;module&quot;,\r\n    &quot;imports&quot;: {\r\n        &quot;#root\/*&quot;: &quot;.\/dist\/*&quot;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>This allows modules in <code>my-package<\/code> to import from paths starting with <code>#root\/<\/code><\/p>\n<pre class=\"prettyprint language-javascript\" style=\"padding: 10px;border-radius: 10px;\"><code>import * as utils from &quot;#root\/utils.js&quot;;\r\n<\/code><\/pre>\n<p>instead of using a relative path like the following.<\/p>\n<pre class=\"prettyprint language-javascript\" style=\"padding: 10px;border-radius: 10px;\"><code>import * as utils from &quot;..\/..\/utils.js&quot;;\r\n<\/code><\/pre>\n<p>One minor annoyance with this feature has been that developers always had to write <em>something<\/em> after the <code>#<\/code> when specifying a subpath import.\nHere, we used <code>root<\/code>, but it is a bit useless since there is no directory we&#8217;re mapping over other than <code>.\/dist\/<\/code><\/p>\n<p>Developers who have used bundlers are also accustomed to using path-mapping to avoid long relative paths.\nA familiar convention with bundlers has been to use a simple <code>@\/<\/code> as the prefix.\nUnfortunately, subpath imports could not start with <code>#\/<\/code> at all, leading to a lot of confusion for developers trying to adopt them in their projects.<\/p>\n<p>But more recently, <a href=\"https:\/\/github.com\/nodejs\/node\/pull\/60864\">Node.js added support for subpath imports starting with <code>#\/<\/code><\/a>.\nThis allows packages to use a simple <code>#\/<\/code> prefix for their subpath imports without needing to add an extra segment.<\/p>\n<pre class=\"prettyprint language-json\" style=\"padding: 10px;border-radius: 10px;\"><code>{\r\n    &quot;name&quot;: &quot;my-package&quot;,\r\n    &quot;type&quot;: &quot;module&quot;,\r\n    &quot;imports&quot;: {\r\n        &quot;#\/*&quot;: &quot;.\/dist\/*&quot;\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>This is supported in newer Node.js 20 releases, and so TypeScript now supports it under the options <code>nodenext<\/code> and <code>bundler<\/code> for the <code>--moduleResolution<\/code> setting.<\/p>\n<p>This work was done thanks to <a href=\"https:\/\/github.com\/magic-akari\">magic-akari<\/a>, and <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62844\">the implementing pull request can be found here<\/a>.<\/p>\n<h2 id=\"combining---moduleresolution-bundler-with---module-commonjs\">Combining <code>--moduleResolution bundler<\/code> with <code>--module commonjs<\/code><\/h2>\n<p>TypeScript&#8217;s <code>--moduleResolution bundler<\/code> setting was previously only allowed to be used with <code>--module esnext<\/code> or <code>--module preserve<\/code>;\nhowever, with the deprecation of <code>--moduleResolution node<\/code> (a.k.a. <code>--moduleResolution node10<\/code>), this new combination is often the most suitable upgrade path for many projects.<\/p>\n<p>Projects will often want to instead plan out a migration towards either<\/p>\n<ul>\n<li><code>--module preserve<\/code> and <code>--moduleResolution bundler<\/code><\/li>\n<li><code>--module nodenext<\/code><\/li>\n<\/ul>\n<p>depending on your project type (e.g. bundled web app, Bun app, or Node.js app).<\/p>\n<p>More information can be found at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62320\">this implementing pull request<\/a>.<\/p>\n<h2 id=\"the---stabletypeordering-flag\">The <code>--stableTypeOrdering<\/code> Flag<\/h2>\n<p>As part of our ongoing work on <a href=\"https:\/\/devblogs.microsoft.com\/typescript\/typescript-native-port\/\">TypeScript&#8217;s native port<\/a>, we&#8217;ve introduced a new flag called <code>--stableTypeOrdering<\/code> intended to assist with 6.0-to-7.0 migrations.<\/p>\n<p>Today, TypeScript assigns type IDs (internal tracking numbers) to types in the order they are encountered, and uses these IDs to sort union types in a consistent manner.\nA similar process occurs for properties.\nAs a result, the order in which things are declared in a program can have possibly surprising effects on things like declaration emit.<\/p>\n<p>For example, consider the declaration emit from this file:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ Input: some-file.ts\r\nexport function foo(condition: boolean) {\r\n    return condition ? 100 : 500;\r\n}\r\n\r\n\/\/ Output: some-file.d.ts\r\nexport declare function foo(condition: boolean): 100 | 500;\r\n\/\/                                               ^^^^^^^^^\r\n\/\/             Note the order of this union: 100, then 500.\r\n<\/code><\/pre>\n<p>If we add an unrelated <code>const<\/code> <em>above<\/em> <code>foo<\/code>, the declaration emit changes:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ Input: some-file.ts\r\nconst x = 500;\r\nexport function foo(condition: boolean) {\r\n    return condition ? 100 : 500;\r\n}\r\n\r\n\/\/ Output: some-file.d.ts\r\nexport declare function foo(condition: boolean): 500 | 100;\r\n\/\/                                               ^^^^^^^^^\r\n\/\/                           Note the change in order here.\r\n<\/code><\/pre>\n<p>This happens because the literal type <code>500<\/code> gets a lower type ID than <code>100<\/code> because it was processed first when analyzing the <code>const x<\/code> declaration.\nIn very rare cases this change in ordering can even cause errors to appear or disappear based on program processing order, but in general, the main place you might notice this ordering is in the emitted declaration files, or in the way types are displayed in your editor.<\/p>\n<p>One of the major architectural improvements in TypeScript 7 is parallel type checking, which dramatically improves overall check time.\nHowever, parallelism introduces a challenge: when different type-checkers visit nodes, types, and symbols in different orders, the internal IDs assigned to these constructs become non-deterministic.\nThis in turn leads to confusing non-deterministic output, where two files with identical contents in the same program can produce different declaration files, or even calculate different errors when analyzing the same file.\nTo fix this, TypeScript 7.0 sorts its internal objects (e.g. types and symbols) according to a deterministic algorithm based on the content of the object.\nThis ensures that all checkers encounter the same object order regardless of how and when they were created.\nAs a consequence, in the given example, TypeScript 7 will <em>always<\/em> print <code>100 | 500<\/code>, removing the ordering instability entirely.<\/p>\n<p>This means that TypeScript 6 and 7 can and do sometimes display different ordering.\nWhile these ordering changes are almost always benign, if you&#8217;re comparing compiler outputs between runs (for example, checking emitted declaration files in 6.0 vs 7.0), these different orderings can produce a lot of noise that makes it difficult to assess correctness.\nOccasionally though, you may witness a change in ordering that causes a type error to appear or disappear, which can be even more confusing.<\/p>\n<p>To help with this situation, in 6.0, you can specify the new <code>--stableTypeOrdering<\/code> flag.\nThis makes 6.0&#8217;s type ordering behavior match 7.0&#8217;s, reducing the number of differences between the two codebases.\nNote that we don&#8217;t necessarily encourage using this flag all the time as it can add a substantial slowdown to type-checking (up to 25% depending on codebase).<\/p>\n<p>If you encounter a type error using <code>--stableTypeOrdering<\/code>, this is typically due to inference differences.\nThe previous inference without <code>--stableTypeOrdering<\/code> <em>happened<\/em> to work based on the current ordering of types in your program.\nTo help with this, you&#8217;ll often benefit from providing an explicit type somewhere.\nOften, this will be a type argument<\/p>\n<pre class=\"prettyprint language-diff\" style=\"padding: 10px;border-radius: 10px;\"><code>- someFunctionCall(\/*...*\/);\r\n+ someFunctionCall&lt;SomeExplicitType&gt;(\/*...*\/);\r\n<\/code><\/pre>\n<p>or a variable annotation for an argument you intend to pass into a call.<\/p>\n<pre class=\"prettyprint language-diff\" style=\"padding: 10px;border-radius: 10px;\"><code>- const someVariable = { \/*... some complex object ...*\/ };\r\n+ const someVariable: SomeExplicitType = { \/*... some complex object ...*\/ };\r\n\r\nsomeFunctionCall(someVariable);\r\n<\/code><\/pre>\n<p><strong>Note that this flag is only intended to help diagnose differences between 6.0 and 7.0 &#8211; it is not intended to be used as a long-term feature<\/strong><\/p>\n<p><a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63084\">See more at this pull-request<\/a>.<\/p>\n<h2 id=\"es2025-option-for-target-and-lib\"><code>es2025<\/code> option for <code>target<\/code> and <code>lib<\/code><\/h2>\n<p>TypeScript 6.0 adds support for the <code>es2025<\/code> option for both <code>target<\/code> and <code>lib<\/code>.\nWhile there are no new JavaScript language features in ES2025, this new target adds new types for built-in APIs (e.g. <code>RegExp.escape<\/code>), and moves a few declarations from <code>esnext<\/code> into <code>es2025<\/code> (e.g. <code>Promise.try<\/code>, <code>Iterator<\/code> methods, and <code>Set<\/code> methods).\nWork to enable <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63046\">the new target<\/a> was contributed thanks to <a href=\"https:\/\/github.com\/petamoriken\">Kenta Moriuchi<\/a>.<\/p>\n<h2 id=\"new-types-for-temporal\">New Types for <code>Temporal<\/code><\/h2>\n<p>The long-awaited <a href=\"https:\/\/github.com\/tc39\/proposal-temporal\">Temporal proposal<\/a> has reached stage 4 and will be part of a future ECMAScript standard.\nTypeScript 6.0 now includes built-in types for the Temporal API, so you can start using it in your TypeScript code today via <code>--target esnext<\/code> or <code>&quot;lib&quot;: [&quot;esnext&quot;]<\/code> (or the more-granular <code>esnext.temporal<\/code>).<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>let yesterday = Temporal.Now.instant().subtract({\r\n    hours: 24,\r\n});\r\n\r\nlet tomorrow = Temporal.Now.instant().add({\r\n    hours: 24,\r\n});\r\n\r\nconsole.log(`Yesterday: ${yesterday}`);\r\nconsole.log(`Tomorrow: ${tomorrow}`);\r\n<\/code><\/pre>\n<p>Temporal is already usable in several runtimes, and with stage 4 status it is now officially part of the JavaScript language.\n<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Global_Objects\/Temporal\">Documentation on the Temporal APIs is available on MDN<\/a>.<\/p>\n<p><a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62628\">This work<\/a> was contributed thanks to GitHub user <a href=\"https:\/\/github.com\/Renegade334\">Renegade334<\/a>.<\/p>\n<h2 id=\"new-types-for-upsert-methods-aka-getorinsert\">New Types for &quot;upsert&quot; Methods (a.k.a. <code>getOrInsert<\/code>)<\/h2>\n<p>A common pattern with <code>Map<\/code>s is to check if a key exists, and if not, set and fetch a default value.<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>function processOptions(compilerOptions: Map&lt;string, unknown&gt;) {\r\n    let strictValue: unknown;\r\n    if (compilerOptions.has(&quot;strict&quot;)) {\r\n        strictValue = compilerOptions.get(&quot;strict&quot;);\r\n    }\r\n    else {\r\n        strictValue = true;\r\n        compilerOptions.set(&quot;strict&quot;, strictValue);\r\n    }\r\n    \/\/ ...\r\n}\r\n<\/code><\/pre>\n<p>This pattern can be tedious.\n<a href=\"https:\/\/github.com\/tc39\/proposal-upsert\">ECMAScript&#8217;s &quot;upsert&quot; proposal<\/a> recently reached stage 4, and introduces 2 new methods on <code>Map<\/code> and <code>WeakMap<\/code>:<\/p>\n<ul>\n<li><code>getOrInsert<\/code><\/li>\n<li><code>getOrInsertComputed<\/code><\/li>\n<\/ul>\n<p>These methods have been added to the <code>esnext<\/code> lib so that you can start using them immediately in TypeScript 6.0.<\/p>\n<p>With <code>getOrInsert<\/code>, we can replace our code above with the following:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>function processOptions(compilerOptions: Map&lt;string, unknown&gt;) {\r\n    let strictValue = compilerOptions.getOrInsert(&quot;strict&quot;, true);\r\n    \/\/ ...\r\n}\r\n<\/code><\/pre>\n<p><code>getOrInsertComputed<\/code> works similarly, but is for cases where the default value may be expensive to compute (e.g. requires lots of computations, allocations, or does long-running synchronous I\/O).\nInstead, it takes a callback that will only be called if the key is not already present.<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>someMap.getOrInsertComputed(&quot;someKey&quot;, () =&gt; {\r\n    return computeSomeExpensiveValue(\/*...*\/);\r\n});\r\n<\/code><\/pre>\n<p>This callback is also given the key as an argument, which can be useful for cases where the default value is based on the key.<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>someMap.getOrInsertComputed(someKey, computeSomeExpensiveDefaultValue);\r\n\r\nfunction computeSomeExpensiveValue(key: string) {\r\n    \/\/ ...\r\n}\r\n<\/code><\/pre>\n<p><a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62612\">This update<\/a> was contributed thanks to GitHub user <a href=\"https:\/\/github.com\/Renegade334\">Renegade334<\/a>.<\/p>\n<h2 id=\"regexpescape\"><code>RegExp.escape<\/code><\/h2>\n<p>When constructing some literal string to match within a regular expression, it is important to escape special regular expression characters like <code>*<\/code>, <code>+<\/code>, <code>?<\/code>, <code>(<\/code>, <code>)<\/code>, etc.\nThe <a href=\"https:\/\/github.com\/tc39\/proposal-regex-escaping\">RegExp Escaping ECMAScript proposal<\/a> has reached stage 4, and introduces a new <code>RegExp.escape<\/code> function that takes care of this for you.<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>function matchWholeWord(word: string, text: string) {\r\n    const escapedWord = RegExp.escape(word);\r\n    const regex = new RegExp(`\\\\b${escapedWord}\\\\b`, &quot;g&quot;);\r\n    return text.match(regex);\r\n}\r\n<\/code><\/pre>\n<p><code>RegExp.escape<\/code> is available in the <code>es2025<\/code> lib, so you can start using it in TypeScript 6.0 today.<\/p>\n<p><a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63046\">This work<\/a> was contributed thanks <a href=\"https:\/\/github.com\/petamoriken\">Kenta Moriuchi<\/a>.<\/p>\n<h2 id=\"the-dom-lib-now-contains-domiterable-and-domasynciterable\">The <code>dom<\/code> lib Now Contains <code>dom.iterable<\/code> and <code>dom.asynciterable<\/code><\/h2>\n<p>TypeScript&#8217;s <code>lib<\/code> option allows you to specify which global declarations your target runtime has.\nOne option is <code>dom<\/code> to represent web environments (i.e. browsers, who implement <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/API\/Document_Object_Model\">the DOM APIs<\/a>).\nPreviously, the DOM APIs were partially split out into <code>dom.iterable<\/code> and <code>dom.asynciterable<\/code> for environments that didn&#8217;t support <code>Iterable<\/code>s and <code>AsyncIterable<\/code>s.\nThis meant that you had to explicitly add <code>dom.iterable<\/code> to use iteration methods on DOM collections like <code>NodeList<\/code> or <code>HTMLCollection<\/code>.<\/p>\n<p>In TypeScript 6.0, the contents of <code>lib.dom.iterable.d.ts<\/code> and <code>lib.dom.asynciterable.d.ts<\/code> are fully included in <code>lib.dom.d.ts<\/code>.\nYou can still reference <code>dom.iterable<\/code> and <code>dom.asynciterable<\/code> in your configuration file&#8217;s <code>&quot;lib&quot;<\/code> array, but they are now just empty files.<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ Before TypeScript 6.0, this required &quot;lib&quot;: [&quot;dom&quot;, &quot;dom.iterable&quot;]\r\n\/\/ Now it works with just &quot;lib&quot;: [&quot;dom&quot;]\r\nfor (const element of document.querySelectorAll(&quot;div&quot;)) {\r\n    console.log(element.textContent);\r\n}\r\n<\/code><\/pre>\n<p>This is a quality-of-life improvement that eliminates a common point of confusion, since no major modern browser lacks these capabilities.\nIf you were already including both <code>dom<\/code> and <code>dom.iterable<\/code>, you can now simplify to just <code>dom<\/code>.<\/p>\n<p>See more <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/60959\">at this issue<\/a> and its <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62111\">corresponding pull request<\/a>.<\/p>\n<h2 id=\"breaking-changes-and-deprecations-in-typescript-60\">Breaking Changes and Deprecations in TypeScript 6.0<\/h2>\n<p>TypeScript 6.0 arrives as a significant transition release, designed to prepare developers for TypeScript 7.0, the upcoming native port of the TypeScript compiler.\nWhile TypeScript 6.0 maintains full compatibility with your existing TypeScript knowledge and continues to be API compatible with TypeScript 5.9, this release introduces a number of breaking changes and deprecations that reflect the evolving JavaScript ecosystem and set the stage for TypeScript 7.0.<\/p>\n<p>In the two years since TypeScript 5.0, we&#8217;ve seen ongoing shifts in how developers write and ship JavaScript:<\/p>\n<ul>\n<li>Virtually every runtime environment is now &quot;evergreen&quot;. True legacy environments (ES5) are vanishingly rare.<\/li>\n<li>Bundlers and ESM have become the most common module targets for new projects, though CommonJS remains a major target. AMD and other in-browser userland module systems are much rarer than they were in 2012.<\/li>\n<li>Almost all packages can be consumed through some module system. UMD packages still exist, but virtually no new code is available <em>only<\/em> as a global variable.<\/li>\n<li><code>tsconfig.json<\/code> is nearly universal as a configuration mechanism.<\/li>\n<li>Appetite for &quot;stricter&quot; typing continues to grow.<\/li>\n<li>TypeScript build performance is top of mind. Despite the gains of TypeScript 7, performance must always remain a key goal, and options which can&#8217;t be supported in a performant way need to be more strongly justified.<\/li>\n<\/ul>\n<p>So TypeScript 6.0 and 7.0 are designed with these realities in mind.\nFor TypeScript 6.0, these deprecations can be ignored by setting <code>&quot;ignoreDeprecations&quot;: &quot;6.0&quot;<\/code> in your tsconfig; however, note that TypeScript 7.0 <em>will not<\/em> support any of these deprecated options.<\/p>\n<p>Some necessary adjustments can be automatically performed with a codemod or tool.\nFor example, the <a href=\"https:\/\/github.com\/andrewbranch\/ts5to6\">experimental <code>ts5to6<\/code> tool<\/a> can automatically adjust <code>baseUrl<\/code> and <code>rootDir<\/code> across your codebase.<\/p>\n<h3 id=\"up-front-adjustments\">Up-Front Adjustments<\/h3>\n<p>We&#8217;ll cover specific adjustments below, but we have to note that some deprecations and behavior changes do not necessarily have an error message that directly points to the underlying issue.\nSo we&#8217;ll note up-front that <strong>many projects will need to do at least one of the following<\/strong>:<\/p>\n<ul>\n<li>\n<p>Set the <code>&quot;types&quot;<\/code> array in tsconfig, typically to <code>&quot;types&quot;: [&quot;node&quot;]<\/code>.<\/p>\n<p><code>&quot;types&quot;: [&quot;*&quot;]<\/code> will restore the 5.9 behavior, but we recommend using an explicit array to improve build performance and predictability.<\/p>\n<p>You&#8217;ll typically know this is the issue if you see a <em>lot<\/em> of type errors related to missing identifiers or unresolved built-in modules.<\/p>\n<\/li>\n<li>\n<p>Set <code>&quot;rootDir&quot;: &quot;.\/src&quot;<\/code> if you were previously relying on this being inferred<\/p>\n<p>You&#8217;ll often know this is the issue if you see files being written to <code>.\/dist\/src\/index.js<\/code> instead of <code>.\/dist\/index.js<\/code>.<\/p>\n<\/li>\n<\/ul>\n<h3 id=\"simple-default-changes\">Simple Default Changes<\/h3>\n<p>Several compiler options now have updated default values that better reflect modern development practices.<\/p>\n<ul>\n<li>\n<p><strong><code>strict<\/code> is now <code>true<\/code> by default<\/strong>:\nThe appetite for stricter typing continues to grow, and we&#8217;ve found that most new projects want <code>strict<\/code> mode enabled.\nIf you were already using <code>&quot;strict&quot;: true<\/code>, nothing changes for you.\nIf you were relying on the previous default of <code>false<\/code>, you&#8217;ll need to explicitly set <code>&quot;strict&quot;: false<\/code> in your <code>tsconfig.json<\/code>.<\/p>\n<\/li>\n<li>\n<p><strong><code>module<\/code> defaults to <code>esnext<\/code><\/strong>:\nSimilarly, the new default <code>module<\/code> is <code>esnext<\/code>, acknowledging that ESM is now the dominant module format.<\/p>\n<\/li>\n<li>\n<p><strong><code>target<\/code> defaults to current-year ES version<\/strong>:\nThe new default <code>target<\/code> is the most recent supported ECMAScript spec version (effectively a floating target).\nRight now, that target is <code>es2025<\/code>.\nThis reflects the reality that most developers are shipping to evergreen runtimes and don&#8217;t need to transpile down to older ECMAScript versions.<\/p>\n<\/li>\n<li>\n<p><strong><code>noUncheckedSideEffectImports<\/code> is now <code>true<\/code> by default<\/strong>:\nThis helps catch issues with typos in side-effect-only imports.<\/p>\n<\/li>\n<li>\n<p><strong><code>libReplacement<\/code> is now <code>false<\/code> by default<\/strong>:\nThis flag previously incurred a large number of failed module resolutions for every run, which in turn increased the number of locations we needed to watch under <code>--watch<\/code> and editor scenarios.\nIn a new project, <code>libReplacement<\/code> never does anything until other explicit configuration takes place, so it makes sense to turn this off by default for the sake of better performance by default.<\/p>\n<\/li>\n<\/ul>\n<p>If these new defaults break your project, you can specify the previous values explicitly in your <code>tsconfig.json<\/code>.<\/p>\n<h3 id=\"rootdir-now-defaults-to\"><code>rootDir<\/code> now defaults to <code>.<\/code><\/h3>\n<p><code>rootDir<\/code> controls the directory structure of your output files relative to the output directory.\nPreviously, if you did not specify a <code>rootDir<\/code>, it was inferred based on the common directory of all non-declaration input files.\nBut this often meant that it was impossible to know if a file belonged to a project without trying to load and parse that project.\nIt also meant that TypeScript had to spend more time inferring that common source directory by analyzing every file path in the program.<\/p>\n<p>In TypeScript 6.0, the default <code>rootDir<\/code> will always be the directory containing the <code>tsconfig.json<\/code> file.\n<code>rootDir<\/code> will only be inferred when using <code>tsc<\/code> from the command line without a <code>tsconfig.json<\/code> file.<\/p>\n<p>If you have source files any level deeper than your <code>tsconfig.json<\/code> directory and were relying on TypeScript to infer a common root directory for source files, you&#8217;ll need to explicitly set <code>rootDir<\/code>:<\/p>\n<pre class=\"prettyprint language-diff\" style=\"padding: 10px;border-radius: 10px;\"><code>  {\r\n      &quot;compilerOptions&quot;: {\r\n          \/\/ ...\r\n+         &quot;rootDir&quot;: &quot;.\/src&quot;\r\n      },\r\n      &quot;include&quot;: [&quot;.\/src&quot;]\r\n  }\r\n<\/code><\/pre>\n<p>Likewise, if your <code>tsconfig.json<\/code> referenced files outside of the containing <code>tsconfig.json<\/code>, you would need to adjust your <code>rootDir<\/code> to include those files.<\/p>\n<pre class=\"prettyprint language-diff\" style=\"padding: 10px;border-radius: 10px;\"><code>  {\r\n      &quot;compilerOptions&quot;: {\r\n          \/\/ ...\r\n+         &quot;rootDir&quot;: &quot;..\/src&quot;\r\n      },\r\n      &quot;include&quot;: [&quot;..\/src\/**\/*.tests.ts&quot;]\r\n  }\r\n<\/code><\/pre>\n<p>See more at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62194\">the discussion here<\/a> and <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62418\">the implementation here<\/a>.<\/p>\n<h3 id=\"types-now-defaults-to\"><code>types<\/code> now defaults to <code>[]<\/code><\/h3>\n<p>In a <code>tsconfig.json<\/code>, the <code>types<\/code> field of <code>compilerOptions<\/code> specifies a list of package names to be included in the global scope during compilation.\nTypically, packages in <code>node_modules<\/code> are automatically included via imports in your source code;\nbut for convenience, TypeScript would also include all packages in <code>node_modules\/@types<\/code> by default, so that you can get global declarations like <code>process<\/code> or the <code>&quot;fs&quot;<\/code> module from <code>@types\/node<\/code>, or <code>describe<\/code> and <code>it<\/code> from <code>@types\/jest<\/code>, without needing to import them directly.<\/p>\n<p>In a sense, the <code>types<\/code> value previously defaulted to &quot;enumerate everything in <code>node_modules\/@types<\/code>&quot;.\nThis can be <em>very<\/em> expensive, as a normal repository setup these days might transitively pull in hundreds of <code>@types<\/code> packages, especially in multi-project workspaces with flattened <code>node_modules<\/code>.\nModern projects almost always need only <code>@types\/node<\/code>, <code>@types\/jest<\/code>, or a handful of other common global-affecting packages.<\/p>\n<p>In TypeScript 6.0, the default <code>types<\/code> value will be <code>[]<\/code> (an empty array).\nThis change prevents projects from unintentionally pulling in hundreds or even thousands of unneeded declaration files at build time.\nMany projects we&#8217;ve looked at have improved their build time anywhere from 20-50% just by setting <code>types<\/code> appropriately.<\/p>\n<p><strong>This will affect many projects.<\/strong> You will likely need to add <code>&quot;types&quot;: [&quot;node&quot;]<\/code> or a few others:<\/p>\n<pre class=\"prettyprint language-diff\" style=\"padding: 10px;border-radius: 10px;\"><code>  {\r\n      &quot;compilerOptions&quot;: {\r\n          \/\/ Explicitly list the @types packages you need\r\n+         &quot;types&quot;: [&quot;node&quot;, &quot;jest&quot;]\r\n      }\r\n  }\r\n<\/code><\/pre>\n<p>You can also specify a <code>*<\/code> entry to re-enable the old enumeration behavior:<\/p>\n<pre class=\"prettyprint language-diff\" style=\"padding: 10px;border-radius: 10px;\"><code>  {\r\n      &quot;compilerOptions&quot;: {\r\n          \/\/ Load ALL the types - the default from TypeScript 5.9 and before.\r\n+         &quot;types&quot;: [&quot;*&quot;]\r\n      }\r\n  }\r\n<\/code><\/pre>\n<p>If you end up with new error messages like the following:<\/p>\n<pre class=\"language-text\" style=\"padding: 10px;border-radius: 10px;\"><code>Cannot find module '...' or its corresponding type declarations.\r\nCannot find name 'fs'. Do you need to install type definitions for node? Try `npm i --save-dev @types\/node` and then add 'node' to the types field in your tsconfig.\r\nCannot find name 'path'. Do you need to install type definitions for node? Try `npm i --save-dev @types\/node` and then add 'node' to the types field in your tsconfig.\r\nCannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types\/node` and then add 'node' to the types field in your tsconfig.\r\nCannot find name 'Bun'. Do you need to install type definitions for Bun? Try `npm i --save-dev @types\/bun` and then add 'bun' to the types field in your tsconfig.\r\nCannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i --save-dev @types\/jest` or `npm i --save-dev @types\/mocha` and then add 'jest' or 'mocha' to the types field in your tsconfig.\r\n<\/code><\/pre>\n<p>it&#8217;s likely that you need to add some entries to your <code>types<\/code> field.<\/p>\n<p>See more at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62195\">the proposal here<\/a> along with <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63054\">the implementing pull request here<\/a>.<\/p>\n<h3 id=\"deprecated-target-es5\">Deprecated: <code>target: es5<\/code><\/h3>\n<p>The ECMAScript 5 target was important for a long time to support legacy browsers; but its successor, ECMAScript 2015 (ES6), was released over a decade ago, and all modern browsers have supported it for many years.\nWith Internet Explorer&#8217;s retirement, and the universality of evergreen browsers, there are very few use cases for ES5 output today.<\/p>\n<p>TypeScript&#8217;s lowest target will now be ES2015, and the <code>target: es5<\/code> option is deprecated. If you were using <code>target: es5<\/code>, you&#8217;ll need to migrate to a newer target or use an external compiler.\nIf you still need ES5 output, we recommend using an external compiler to either directly compile your TypeScript source, or to post-process TypeScript&#8217;s outputs.<\/p>\n<p><a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62196\">See more about this deprecation here<\/a> along with <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63067\">its implementing pull request<\/a>.<\/p>\n<h3 id=\"deprecated---downleveliteration\">Deprecated: <code>--downlevelIteration<\/code><\/h3>\n<p><code>--downlevelIteration<\/code> only has effects on ES5 emit, and since <code>--target es5<\/code> has been deprecated, <code>--downlevelIteration<\/code> no longer serves a purpose.<\/p>\n<p>Subtly, using <code>--downlevelIteration false<\/code> with <code>--target es2015<\/code> did not error in TypeScript 5.9 and earlier, even though it had no effect.\nIn TypeScript 6.0, setting <code>--downlevelIteration<\/code> at all will lead to a deprecation error.<\/p>\n<p>See <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63071\">the implementation here<\/a>.<\/p>\n<h3 id=\"deprecated---moduleresolution-node-aka---moduleresolution-node10\">Deprecated: <code>--moduleResolution node<\/code> (a.k.a. <code>--moduleResolution node10<\/code>)<\/h3>\n<p><code>--moduleResolution node<\/code> encoded a specific version of Node.js&#8217;s module resolution algorithm that most-accurately reflected the behavior of Node.js 10.\nUnfortunately, this target (and its name) ignores many updates to Node.js&#8217;s resolution algorithm that have occurred since then, and it is no longer a good representation of the behavior of modern Node.js versions.<\/p>\n<p>In TypeScript 6.0, <code>--moduleResolution node<\/code> (specifically, <code>--moduleResolution node10<\/code>) is deprecated.\nUsers who were using <code>--moduleResolution node<\/code> should usually migrate to <code>--moduleResolution nodenext<\/code> if they plan on targeting Node.js directly, or <code>--moduleResolution bundler<\/code> if they plan on using a bundler or Bun.<\/p>\n<p>See more <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62200\">at this issue<\/a> and <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62338\">its corresponding pull request<\/a>.<\/p>\n<h3 id=\"deprecated-amd-umd-and-systemjs-values-of-module\">Deprecated: <code>amd<\/code>, <code>umd<\/code>, and <code>systemjs<\/code> values of <code>module<\/code><\/h3>\n<p>The following flag values are no longer supported<\/p>\n<ul>\n<li><code>--module amd<\/code><\/li>\n<li><code>--module umd<\/code><\/li>\n<li><code>--module systemjs<\/code><\/li>\n<li><code>--module none<\/code><\/li>\n<\/ul>\n<p>AMD, UMD, and SystemJS were important during the early days of JavaScript modules when browsers lacked native module support.\nThe semantics of &quot;none&quot; were never well-defined and often led to confusion.\nToday, ESM is universally supported in browsers and Node.js, and both import maps and bundlers have become favored ways for filling in the gaps.\nIf you&#8217;re still targeting these module systems, consider migrating to an appropriate ECMAScript module-emitting target, adopt a bundler or different compiler, or stay on TypeScript 5.x until you can migrate.<\/p>\n<p>This also implies dropped support for the <code>amd-module<\/code> directive, which will no longer have any effect.<\/p>\n<p>See more at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62199\">the proposal issue<\/a> along with <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62669\">the implementing pull request<\/a>.<\/p>\n<h3 id=\"deprecated---baseurl\">Deprecated: <code>--baseUrl<\/code><\/h3>\n<p>The <code>baseUrl<\/code> option is most-commonly used in conjunction with <code>paths<\/code>, and is typically used as a prefix for every value in <code>paths<\/code>.\nUnfortunately, <code>baseUrl<\/code> is also considered a look-up root for module resolution.<\/p>\n<p>For example, given the following <code>tsconfig.json<\/code><\/p>\n<pre class=\"prettyprint language-json\" style=\"padding: 10px;border-radius: 10px;\"><code>{\r\n  &quot;compilerOptions&quot;: {\r\n    \/\/ ...\r\n    &quot;baseUrl&quot;: &quot;.\/src&quot;,\r\n    &quot;paths&quot;: {\r\n      &quot;@app\/*&quot;: [&quot;app\/*&quot;],\r\n      &quot;@lib\/*&quot;: [&quot;lib\/*&quot;]\r\n    }\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>and an import like<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>import * as someModule from &quot;someModule.js&quot;;\r\n<\/code><\/pre>\n<p>TypeScript will probably resolve this to <code>src\/someModule.js<\/code>, even if the developer only intended to add mappings for modules starting with <code>@app\/<\/code> and <code>@lib\/<\/code>.<\/p>\n<p>In the best case, this also often leads to &quot;worse-looking&quot; paths that bundlers would ignore;\nbut it often meant that that many import paths that would never have worked at runtime are considered &quot;just fine&quot; by TypeScript.<\/p>\n<p><code>path<\/code> mappings have not required specifying <code>baseUrl<\/code> for a long time, and in practice, most projects that use <code>baseUrl<\/code> only use it as a prefix for their <code>paths<\/code> entries.\nIn TypeScript 6.0, <code>baseUrl<\/code> is deprecated and will no longer be considered a look-up root for module resolution.<\/p>\n<p>Developers who used <code>baseUrl<\/code> as a prefix for path-mapping entries can simply remove <code>baseUrl<\/code> and add the prefix to their <code>paths<\/code> entries:<\/p>\n<pre class=\"prettyprint language-diff\" style=\"padding: 10px;border-radius: 10px;\"><code>  {\r\n    &quot;compilerOptions&quot;: {\r\n      \/\/ ...\r\n-     &quot;baseUrl&quot;: &quot;.\/src&quot;,\r\n      &quot;paths&quot;: {\r\n-       &quot;@app\/*&quot;: [&quot;app\/*&quot;],\r\n-       &quot;@lib\/*&quot;: [&quot;lib\/*&quot;]\r\n+       &quot;@app\/*&quot;: [&quot;.\/src\/app\/*&quot;],\r\n+       &quot;@lib\/*&quot;: [&quot;.\/src\/lib\/*&quot;]\r\n      }\r\n    }\r\n  }\r\n<\/code><\/pre>\n<p>Developers who actually <em>did<\/em> use <code>baseUrl<\/code> as a look-up root can also add an explicit path mapping to preserve the old behavior:<\/p>\n<pre class=\"prettyprint language-json\" style=\"padding: 10px;border-radius: 10px;\"><code>{\r\n  &quot;compilerOptions&quot;: {\r\n    \/\/ ...\r\n    &quot;paths&quot;: {\r\n      \/\/ A new catch-all that replaces the baseUrl:\r\n      &quot;*&quot;: [&quot;.\/src\/*&quot;],\r\n\r\n      \/\/ Every other path now has an explicit common prefix:\r\n      &quot;@app\/*&quot;: [&quot;.\/src\/app\/*&quot;],\r\n      &quot;@lib\/*&quot;: [&quot;.\/src\/lib\/*&quot;],\r\n    }\r\n  }\r\n}\r\n<\/code><\/pre>\n<p>However, this is extremely rare.\nWe recommend most developers simply remove <code>baseUrl<\/code> and add the appropriate prefixes to their <code>paths<\/code> entries.<\/p>\n<p>See more <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62207\">at this issue<\/a> and <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62509\">the corresponding pull request<\/a>.<\/p>\n<h3 id=\"deprecated---moduleresolution-classic\">Deprecated: <code>--moduleResolution classic<\/code><\/h3>\n<p>The <code>moduleResolution: classic<\/code> setting has been removed.\nThe <code>classic<\/code> resolution strategy was TypeScript&#8217;s original module resolution algorithm, and predates Node.js&#8217;s resolution algorithm becoming a de facto standard.\nToday, all practical use cases are served by <code>nodenext<\/code> or <code>bundler<\/code>.\nIf you were using <code>classic<\/code>, migrate to one of these modern resolution strategies.<\/p>\n<p>See more at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62206\">this issue<\/a> and <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62669\">the implementing pull request<\/a>.<\/p>\n<h3 id=\"deprecated---esmoduleinterop-false-and---allowsyntheticdefaultimports-false\">Deprecated: <code>--esModuleInterop false<\/code> and <code>--allowSyntheticDefaultImports false<\/code><\/h3>\n<p>The following settings can no longer be set to <code>false<\/code>:<\/p>\n<ul>\n<li><code>esModuleInterop<\/code><\/li>\n<li><code>allowSyntheticDefaultImports<\/code><\/li>\n<\/ul>\n<p><code>esModuleInterop<\/code> and <code>allowSyntheticDefaultImports<\/code> were originally opt-in to avoid breaking existing projects.\nHowever, the behavior they enable has been the recommended default for years.\nSetting them to <code>false<\/code> often led to subtle runtime issues when consuming CommonJS modules from ESM.\nIn TypeScript 6.0, the safer interop behavior is always enabled.<\/p>\n<p>If you have imports that rely on the old behavior, you may need to adjust them:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ Before (with esModuleInterop: false)\r\nimport * as express from &quot;express&quot;;\r\n\r\n\/\/ After (with esModuleInterop always enabled)\r\nimport express from &quot;express&quot;;\r\n<\/code><\/pre>\n<p>See more at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62529\">this issue<\/a> and <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62567\">its implementing pull request<\/a>.<\/p>\n<h3 id=\"deprecated---alwaysstrict-false\">Deprecated: <code>--alwaysStrict false<\/code><\/h3>\n<p>The <code>alwaysStrict<\/code> flag refers to inference and emit of the <code>&quot;use strict&quot;;<\/code> directive.\nIn TypeScript 6.0, all code will be assumed to be in <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/JavaScript\/Reference\/Strict_mode\">JavaScript strict mode<\/a>, which is a set of JS semantics that most-noticeably affects syntactic corner cases around reserved words.\nIf you have &quot;sloppy mode&quot; code that uses reserved words like <code>await<\/code>, <code>static<\/code>, <code>private<\/code>, or <code>public<\/code> as regular identifiers, you&#8217;ll need to rename them.\nIf you relied on subtle semantics around the meaning of <code>this<\/code> in non-strict code, you may need to adjust your code as well.<\/p>\n<p>See more <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62213\">at this issue<\/a> and <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63089\">its corresponding pull request<\/a>.<\/p>\n<h3 id=\"deprecated-outfile\">Deprecated: <code>outFile<\/code><\/h3>\n<p>The <code>--outFile<\/code> option has been removed from TypeScript 6.0. This option was originally designed to concatenate multiple input files into a single output file. However, external bundlers like Webpack, Rollup, esbuild, Vite, Parcel, and others now do this job faster, better, and with far more configurability. Removing this option simplifies the implementation and allows us to focus on what TypeScript does best: type-checking and declaration emit. If you&#8217;re currently using <code>--outFile<\/code>, you&#8217;ll need to migrate to an external bundler. Most modern bundlers have excellent TypeScript support out of the box.<\/p>\n<h3 id=\"deprecated-legacy-module-syntax-for-namespaces\">Deprecated: legacy <code>module<\/code> Syntax for namespaces<\/h3>\n<p>Early versions of TypeScript used the <code>module<\/code> keyword to declare namespaces:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ \u274c Deprecated syntax - now an error\r\nmodule Foo {\r\n    export const bar = 10;\r\n}\r\n<\/code><\/pre>\n<p>This syntax was later aliased to the modern preferred form using the <code>namespace<\/code> keyword:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ \u2705 The correct syntax\r\nnamespace Foo {\r\n    export const bar = 10;\r\n}\r\n<\/code><\/pre>\n<p>When <code>namespace<\/code> was introduced, the <code>module<\/code> syntax was simply discouraged.\nA few years ago, the TypeScript language service started marking the keyword as deprecated, suggesting <code>namespace<\/code> in its place.<\/p>\n<p>In TypeScript 6.0, using <code>module<\/code> where <code>namespace<\/code> is expected is now a hard deprecation.\nThis change is necessary because <code>module<\/code> blocks are a potential ECMAScript proposal that would conflict with the legacy TypeScript syntax.<\/p>\n<p>The ambient module declaration form remains fully supported:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ \u2705 Still works perfectly\r\ndeclare module &quot;some-module&quot; {\r\n    export function doSomething(): void;\r\n}\r\n<\/code><\/pre>\n<p>See <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62211\">this issue<\/a> and its <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62876\">corresponding pull request<\/a> for more details.<\/p>\n<h3 id=\"deprecated-asserts-keyword-on-imports\">Deprecated: <code>asserts<\/code> Keyword on Imports<\/h3>\n<p>The <code>asserts<\/code> keyword was proposed to the JavaScript language via the import assertions proposal;\nhowever, the proposal eventually morphed into <a href=\"https:\/\/github.com\/tc39\/proposal-import-attributes\">the import attributes proposal<\/a>, which uses the <code>with<\/code> keyword instead of <code>asserts<\/code>.<\/p>\n<p>Thus, the <code>asserts<\/code> syntax is now deprecated in TypeScript 6.0, and using it will lead to an error:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ \u274c Deprecated syntax - now an error.\r\nimport blob from &quot;.\/blahb.json&quot; asserts { type: &quot;json&quot; }\r\n\/\/                              ~~~~~~~\r\n\/\/ error: Import assertions have been replaced by import attributes. Use 'with' instead of 'asserts'.\r\n<\/code><\/pre>\n<p>Instead, use the <code>with<\/code> syntax for import attributes:<\/p>\n<pre class=\"prettyprint language-typescript\" style=\"padding: 10px;border-radius: 10px;\"><code>\/\/ \u2705 Works with the new import attributes syntax.\r\nimport blob from &quot;.\/blahb.json&quot; with { type: &quot;json&quot; }\r\n<\/code><\/pre>\n<p>See more at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62210\">this issue<\/a> and its <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/63077\">corresponding pull request<\/a>.<\/p>\n<h3 id=\"deprecated-no-default-lib-directives\">Deprecated: <code>no-default-lib<\/code> Directives<\/h3>\n<p>The <code>\/\/\/ &lt;reference no-default-lib=&quot;true&quot;\/&gt;<\/code> directive has been largely misunderstood and misused.\nIn TypeScript 6.0, this directive is no longer supported.\nIf you were using it, consider using <code>--noLib<\/code> or <code>--libReplacement<\/code> instead.<\/p>\n<p><a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62209\">See more here<\/a> and at <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62435\">the corresponding pull request<\/a>.<\/p>\n<h3 id=\"specifying-command-line-files-when-tsconfigjson-exists-is-now-an-error\">Specifying Command-Line Files When <code>tsconfig.json<\/code> Exists is Now an Error<\/h3>\n<p>Currently, if you run <code>tsc foo.ts<\/code> in a folder where a <code>tsconfig.json<\/code> exists, the config file is completely ignored.\nThis was often very confusing if you expected checking and emit options to apply to the input file.<\/p>\n<p>In TypeScript 6.0, if you run <code>tsc<\/code> with file arguments in a directory containing a <code>tsconfig.json<\/code>, an error will be issued to make this behavior explicit:<\/p>\n<pre class=\"language-text\" style=\"padding: 10px;border-radius: 10px;\"><code>error TS5112: tsconfig.json is present but will not be loaded if files are specified on commandline. Use '--ignoreConfig' to skip this error.\r\n<\/code><\/pre>\n<p>If it is the case that you wanted to ignore the <code>tsconfig.json<\/code> and just compile <code>foo.ts<\/code> with TypeScript&#8217;s defaults, you can use the new <code>--ignoreConfig<\/code> flag.<\/p>\n<pre class=\"prettyprint language-sh\" style=\"padding: 10px;border-radius: 10px;\"><code>tsc --ignoreConfig foo.ts\r\n<\/code><\/pre>\n<p>See more <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/62197\">at this issue<\/a> and its <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/pull\/62477\">corresponding pull request<\/a>.<\/p>\n<h2 id=\"preparing-for-typescript-70\">Preparing for TypeScript 7.0<\/h2>\n<p>TypeScript 6.0 is designed as a transition release.\nWhile options deprecated in TypeScript 6.0 will continue to work without errors when <code>&quot;ignoreDeprecations&quot;: &quot;6.0&quot;<\/code> is set, those options will be <strong>removed entirely in TypeScript 7.0<\/strong> (the native TypeScript port).\nIf you&#8217;re seeing deprecation warnings after upgrading to TypeScript 6.0, we strongly recommend addressing them before adopting TypeScript 7.0 (or trying <a href=\"https:\/\/www.npmjs.com\/package\/@typescript\/native-preview\">native previews<\/a>) in your project.<\/p>\n<h2 id=\"whats-next\">What&#8217;s Next?<\/h2>\n<p>Now that TypeScript 6.0 is available on npm, the team will be focused on bringing TypeScript 7.0 to stability.\nThis is much closer than it might sound: we expect a release within a few months, and we are already seeing broad adoption inside and outside of Microsoft on extremely large codebases.\nSo we encourage teams to try out nightly builds of TypeScript 7.0&#8217;s <a href=\"https:\/\/www.npmjs.com\/package\/@typescript\/native-preview\">native previews on npm<\/a> along with the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=TypeScriptTeam.native-preview\">VS Code extension too<\/a>.\nFeedback on TypeScript 7.0 will go a long way, and you can file issues <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/issues\">on our issue tracker<\/a>.<\/p>\n<p>Still, TypeScript 6.0 is a stable release that you should be able to adopt today, and it includes a number of improvements and new features that you can start using right away.\nWe hope this release will be a smooth transition for everyone, and we look forward to hearing about your experiences with it.<\/p>\n<p>Happy Hacking!<\/p>\n<p>&#8211; Daniel Rosenwasser and the TypeScript Team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today we are excited to announce the availability of TypeScript 6.0! If you are not familiar with TypeScript, it&#8217;s a language that builds on JavaScript by adding syntax for types, which enables type-checking to catch errors, and provide rich editor tooling. You can learn more about TypeScript and how to get started on the TypeScript [&hellip;]<\/p>\n","protected":false},"author":381,"featured_media":5108,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-typescript"],"acf":[],"blog_post_summary":"<p>Today we are excited to announce the availability of TypeScript 6.0! If you are not familiar with TypeScript, it&#8217;s a language that builds on JavaScript by adding syntax for types, which enables type-checking to catch errors, and provide rich editor tooling. You can learn more about TypeScript and how to get started on the TypeScript [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/5106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/users\/381"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/comments?post=5106"}],"version-history":[{"count":1,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/5106\/revisions"}],"predecessor-version":[{"id":5111,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/5106\/revisions\/5111"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media\/5108"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media?parent=5106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/categories?post=5106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/tags?post=5106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}