{"id":4886,"date":"2025-05-22T07:04:21","date_gmt":"2025-05-22T15:04:21","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/typescript\/?p=4886"},"modified":"2025-12-11T23:10:30","modified_gmt":"2025-12-12T07:10:30","slug":"announcing-typescript-native-previews","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/typescript\/announcing-typescript-native-previews\/","title":{"rendered":"Announcing TypeScript Native Previews"},"content":{"rendered":"<p>This past March <a href=\"https:\/\/devblogs.microsoft.com\/typescript\/typescript-native-port\/\">we unveiled our efforts to port the TypeScript compiler and toolset to native code<\/a>.\nThis port has achieved a 10x speed-up on most projects &#8211; not just by using a natively-compiled language (Go), but also through using shared memory parallelism and concurrency where we can benefit.\nSince then, we have made several strides towards running on large complex real-world projects.<\/p>\n<p>Today, we are excited to announce broad availability of TypeScript Native Previews.\nAs of today, you will be able to use npm to get a preview of the native TypeScript compiler.\nAdditionally, you&#8217;ll be able to use a preview version of our editor functionality for <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=TypeScriptTeam.native-preview\">VS Code through the Visual Studio Marketplace<\/a>.<\/p>\n<p>To get the compiler over npm, you can run the following command in your project:<\/p>\n<pre class=\"prettyprint language-sh\" style=\"padding: 10px; border-radius: 10px;\"><code>npm install -D @typescript\/native-preview\r\n<\/code><\/pre>\n<p>This package provides an executable called <code>tsgo<\/code>.\nThis executable runs similarly to <code>tsc<\/code>, the existing executable that the <code>typescript<\/code> package makes available:<\/p>\n<pre class=\"prettyprint language-sh\" style=\"padding: 10px; border-radius: 10px;\"><code>npx tsgo --project .\/src\/tsconfig.json\r\n<\/code><\/pre>\n<p>Eventually we will rename <code>tsgo<\/code> to <code>tsc<\/code> and move it to the <code>typescript<\/code> package.\nFor now, it lives separately for easier testing.\nThe new executable is still a work in progress, but is suitable to type-check and build many real-world projects.<\/p>\n<p>But we know that a command-line compiler is only half the story.\nWe&#8217;ve heard teams are eager to see what the new editing experience is like too, and so you can now install the new &#8220;TypeScript (Native Preview)&#8221; extension in Visual Studio Code.\nYou can easily install it off of the <a href=\"https:\/\/marketplace.visualstudio.com\/items?itemName=TypeScriptTeam.native-preview\">VS Code Extension Marketplace<\/a>.<\/p>\n<p>Because the extension is still in early stages of development, it defers to the built-in TypeScript extension in VS Code.\nFor that reason, the extension will need to be enabled even after installation.\nYou can do this by opening <a href=\"https:\/\/code.visualstudio.com\/docs\/getstarted\/userinterface#_command-palette\">VS Code&#8217;s command palette<\/a> and running the command &#8220;TypeScript Native Preview: Enable (Experimental)&#8221;.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2025\/05\/native-preview-enable-202505.png\" alt=\"TypeScript Native Preview: Enable (Experimental)\" \/><\/p>\n<p>Alternatively, you can toggle this in your settings UI by configuring &#8220;TypeScript &gt; Experimental: Use Tsgo&#8221;<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2025\/05\/native-preview-use-tsgo-202505-1.png\" alt=\"&quot;Use tsgo&quot; in the VS Code Settings UI\" \/><\/p>\n<p>or by adding the following line to your JSON settings:<\/p>\n<pre class=\"prettyprint language-json\" style=\"padding: 10px; border-radius: 10px;\"><code>\"typescript.experimental.useTsgo\": true,\r\n<\/code><\/pre>\n<h2 id=\"updates-release-cadence-and-roadmap\">Updates, Release Cadence, and Roadmap<\/h2>\n<p>These previews will eventually become TypeScript 7 and will be published nightly so that you can easily try the latest developments on the TypeScript native port effort.\nIf you use the VS Code extension, you should get automatic updates by default.\nIf for whatever reason you find any sort of disruption, we encourage you to <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/issues\">file an issue<\/a> and temporarily disable the new language service with the command &#8220;TypeScript Native Preview: Disable&#8221;:<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/devblogs.microsoft.com\/typescript\/wp-content\/uploads\/sites\/11\/2025\/05\/native-preview-enable-202505.png\" alt=\"TypeScript Native Preview: Disable\" \/><\/p>\n<p>or by configuring any of the settings mentioned above.<\/p>\n<p>Keep in mind, these native previews are missing lots of functionality that stable versions of TypeScript have today.\nThat includes command-line functionality like <code>--build<\/code> (though individual projects can still be built with <code>tsgo<\/code>), <code>--declaration<\/code> emit, and certain downlevel emit targets.\nSimilarly, editor functionality like auto-imports, find-all-references, and rename are still pending implementation.\nBut we encourage developers to check back frequently, as we&#8217;ll be hard at work on these features!<\/p>\n<h2 id=\"whats-new\">What&#8217;s New?<\/h2>\n<p>Since our initial announcement, we have made some notable strides in type-checking support, testability, editor support, and APIs.\nWe would also love to give a brief update of what we&#8217;ve accomplished, plus what&#8217;s on the horizon.<\/p>\n<p>Note that while the native preview will eventually be called TypeScript 7, we&#8217;ve casually been referring to it as &#8220;Project Corsa&#8221; in the meantime.\nWe&#8217;ve also been more explicit in referring to the codebase that makes up TypeScript 5.8 as our current JS-based codebase, or &#8220;Strada&#8221;.\nSo in our updates, you&#8217;ll see us differentiate the native and stable versions of TypeScript as &#8220;Corsa&#8221; (TS7) and &#8220;Strada&#8221; (TS 5.8).<\/p>\n<h3 id=\"fuller-type-checking-support\">Fuller Type-Checking Support<\/h3>\n<p>The majority of the type-checker has been ported at this time.\nThat is to say, most projects should see the same errors apart from those affected by some intentional changes (e.g. <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/pull\/200\">this change to the ordering of types<\/a>) and some stale definitions in <code>lib.d.ts<\/code>.\nIf you see any divergences and differences, we encourage you <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/issues\">to file an issue to let us know<\/a>.<\/p>\n<p>It is worth calling out support for two major type-checking features that have been added since our initial announcement: JSX and JavaScript+JSDoc.<\/p>\n<h3 id=\"jsx-checking-support\">JSX Checking Support<\/h3>\n<p>When developers first got access to the <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/\">TypeScript native port<\/a>, we had to temper expectations.\nWhile type-checking was pretty far along, some constructs were still not fully checked yet.\nFor many developers, the most notable omission was JSX.\nWhile Corsa was able to parse JSX, it would mostly just pass over JSX expressions when type-checking and note that JSX was not-yet supported.<\/p>\n<p>Since then, we&#8217;ve actually added type-checking support for JSX and we can get a better sense of how fast a real JSX project can be built.\nAs an example codebase, we looked at the codebase for <a href=\"https:\/\/github.com\/getsentry\/sentry\/\">Sentry<\/a>.\nIf you run TypeScript 5.8 from the repository root with <code>--extendedDiagnostics --noEmit<\/code>, you&#8217;ll get something like the following:<\/p>\n<pre class=\"language-text\" style=\"padding: 10px; border-radius: 10px;\"><code>$ tsc -p . --noEmit --extendedDiagnostics\r\nFiles:                         9306\r\nLines of Library:             43159\r\nLines of Definitions:        352182\r\nLines of TypeScript:        1113969\r\nLines of JavaScript:           1106\r\nLines of JSON:                  304\r\nLines of Other:                   0\r\nIdentifiers:                1956007\r\nSymbols:                    3563371\r\nTypes:                       999619\r\nInstantiations:             3675199\r\nMemory used:               3356832K\r\nAssignability cache size:    944737\r\nIdentity cache size:          43226\r\nSubtype cache size:          110171\r\nStrict subtype cache size:   430338\r\nI\/O Read time:                1.40s\r\nParse time:                   3.48s\r\nResolveModule time:           1.88s\r\nResolveTypeReference time:    0.02s\r\nResolveLibrary time:          0.01s\r\nProgram time:                 7.78s\r\nBind time:                    1.77s\r\nCheck time:                  63.26s\r\nprintTime time:               0.00s\r\nEmit time:                    0.00s\r\nTotal time:                  72.81s\r\n<\/code><\/pre>\n<p>That&#8217;s over a minute to type-check this codebase!\nLet&#8217;s see how the native port fares with some minimal changes.<\/p>\n<pre class=\"language-text\" style=\"padding: 10px; border-radius: 10px;\"><code>$ tsgo -p . --noEmit --extendedDiagnostics\r\n...\r\nFiles:              9292\r\nLines:           1508361\r\nIdentifiers:     1954236\r\nSymbols:         5011565\r\nTypes:           1689528\r\nInstantiations:  6524885\r\nMemory used:    3892267K\r\nMemory allocs:  61043466\r\nParse time:       0.712s\r\nBind time:        0.133s\r\nCheck time:       5.882s\r\nEmit time:        0.012s\r\nTotal time:       6.761s\r\n<\/code><\/pre>\n<p>There are some discrepancies in results, but Corsa brings build times down from over a minute to just under 7 seconds on the same machine.\nYour results may vary, but in general we&#8217;ve seen consistent speed-ups of over 10x on this specific example.\nYou can try introducing an error in existing JSX code and <code>tsgo<\/code> will catch it.<\/p>\n<p>You can see more over <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/pull\/762\">at our PR to port JSX type-checking<\/a>, plus some follow-on support <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/pull\/780\">for tslib and JSX factory imports<\/a>.<\/p>\n<h3 id=\"javascript-checking\">JavaScript Checking<\/h3>\n<p><a href=\"https:\/\/www.typescriptlang.org\/docs\/handbook\/type-checking-javascript-files.html\">TypeScript supports parsing and type-checking JavaScript files<\/a>.\nBecause valid JavaScript\/ECMAScript doesn&#8217;t support type-specific syntax like annotations or <code>interface<\/code> and <code>type<\/code> declarations, TypeScript looks at JSDoc comments in JS source code for type analysis.<\/p>\n<p>The native previews of TypeScript now also support type-checking JS files.\nIn developing JS type-checking for Corsa, we revisited our early decisions in our implementation.\nJavaScript support was built up in a very organic way and, in turn, analyzed very specific patterns that may no longer be (or may never have been) in widespread use.\nIn order to simplify the new codebase, JavaScript support has been rewritten rather than ported.\nAs a result, there may be some constructs that may need to be rewritten, or to use a more idiomatic\/modern JS style.<\/p>\n<p>If this causes difficulties for your project, we are <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/issues\">open to feedback on the issue tracker<\/a>.<\/p>\n<h3 id=\"editor-support--lsp-progress\">Editor Support &amp; LSP Progress<\/h3>\n<p>When we released the Corsa codebase, it included a very rudimentary LSP-based language server.\nWhile most tangible development has been on the compiler itself, we have been iterating on multiple fronts to port our editor functionality in this new system.\nBecause the Strada codebase communicates with editors via the TSServer format that predates LSP, we are not aiming to do a perfect 1:1 port between the codebases.\nThis means that porting code often requires more manual porting and has required a bit more up-front thought in how we generate type definitions that conform to LSP.\nGathering errors\/diagnostics, go-to-definition, and hover work in very early stages.<\/p>\n<p>Most recently, we have hit another milestone: we have enabled completions!\nWhile auto-imports and other features around completions are not fully ported, this may be enough for many teams in large codebases.\nGoing forward, our priorities are in porting over our existing language server test suite, along with enabling find-all-references, rename, and signature help.<\/p>\n<h3 id=\"api-progress\">API Progress<\/h3>\n<p>A big challenge as part of this port will be continuity with API consumers of TypeScript.\nWe have the initial foundation of an API layer that can be leveraged over standard I\/O.\nThis work means that API consumers can communicate with a TypeScript process through IPC regardless of the consuming language.\nSince we know that many API consumers will be writing TypeScript and JavaScript code, we also have JavaScript-based clients for interacting with the API.<\/p>\n<p>Because so much TypeScript API usage today is synchronous, we wanted to make it possible to communicate with this process in a synchronous way.\nNode.js unfortunately doesn&#8217;t provide an easy way to communicate synchronously with a child process, so we developed a native Node.js module in Rust (which should make lots of people happy) called <a href=\"https:\/\/github.com\/microsoft\/libsyncrpc\">libsyncrpc<\/a>.<\/p>\n<p>We are still in the early days of API design here, but we are open to thoughts and feedback on the matter.\nMore <a href=\"https:\/\/github.com\/microsoft\/typescript-go\/pull\/711\">details about the current API server are available here<\/a>.<\/p>\n<h2 id=\"known-and-notable-differences\">Known and Notable Differences<\/h2>\n<p>As we&#8217;ve mentioned, the Corsa compiler and language service may still have some differences from Strada.\nThere are some differences that you may hit early on in trying out <code>tsgo<\/code> and the Native Preview VS Code extension.<\/p>\n<p>Some of those come from eventual <a href=\"https:\/\/github.com\/microsoft\/TypeScript\/issues\/54500\">TypeScript 6.0 deprecations<\/a>, like <code>node<\/code>\/<code>node10<\/code> resolution (in favor of <code>node16<\/code>, <code>nodenext<\/code>, and <code>bundler<\/code>).\nIf you use <code>--moduleResolution node<\/code> or <code>--module commonjs<\/code>, you may see some errors like:<\/p>\n<pre class=\"language-text\" style=\"padding: 10px; border-radius: 10px;\"><code>Cannot find module 'blah' or its corresponding type declarations.\r\nModule '\"module\"' has no exported member 'Thing'.\r\n<\/code><\/pre>\n<p>You will get consistent errors if you switch your <code>tsconfig.json<\/code> settings to use<\/p>\n<pre class=\"prettyprint language-json\" style=\"padding: 10px; border-radius: 10px;\"><code>{\r\n    \"compilerOptions\": {\r\n        \/\/ ...\r\n        \"module\": \"preserve\",\r\n        \"moduleResolution\": \"bundler\",\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>or<\/p>\n<pre class=\"prettyprint language-json\" style=\"padding: 10px; border-radius: 10px;\"><code>{\r\n    \"compilerOptions\": {\r\n        \/\/ ...\r\n        \"module\": \"nodenext\"\r\n    }\r\n}\r\n<\/code><\/pre>\n<p>These can be manually fixed depending on your configuration, though often you can remove the imports and leverage auto-imports to do &#8220;the right thing&#8221;.<\/p>\n<p>Beyond deprecations, downlevel emit to older targets is limited, and JSX emit only works as far as preserving what you wrote.\nDeclaration emit is currently not supported either.\n<code>--build<\/code> mode and language service functionality around project references is still not available, though project dependencies can be built through <code>tsc<\/code>, and the native preview language service can often leverage generated <code>.d.ts<\/code> files.<\/p>\n<h2 id=\"whats-next\">What&#8217;s Next?<\/h2>\n<p>By later this year, we will aim to have a more complete version of our compiler with major features like <code>--build<\/code>, along with most language service features for editors.<\/p>\n<p>But we don&#8217;t expect you to wait that long!\nAs TypeScript Native Previews are published nightly, we&#8217;ll aim to provide periodic updates on major notable developments.\nSo give the native previews a shot!<\/p>\n<p>Happy Hacking!<\/p>\n<p>&#8211; Daniel Rosenwasser and the TypeScript Team<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This past March we unveiled our efforts to port the TypeScript compiler and toolset to native code. This port has achieved a 10x speed-up on most projects &#8211; not just by using a natively-compiled language (Go), but also through using shared memory parallelism and concurrency where we can benefit. Since then, we have made several [&hellip;]<\/p>\n","protected":false},"author":381,"featured_media":1797,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-4886","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-typescript"],"acf":[],"blog_post_summary":"<p>This past March we unveiled our efforts to port the TypeScript compiler and toolset to native code. This port has achieved a 10x speed-up on most projects &#8211; not just by using a natively-compiled language (Go), but also through using shared memory parallelism and concurrency where we can benefit. Since then, we have made several [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/4886","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=4886"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/posts\/4886\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media\/1797"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/media?parent=4886"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/categories?post=4886"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/typescript\/wp-json\/wp\/v2\/tags?post=4886"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}