www.typescriptlang.org
Open in
urlscan Pro
52.179.188.149
Public Scan
Submitted URL: http://1710215722937.abstractedkirobin.com/e28db810-7e5a-4a2f-99e8-7b14fdd804ab?n=1&t=1710215722937&l_next=ahr0chm6ly93d3cubgf0ywh1z28udg9w...
Effective URL: https://www.typescriptlang.org/
Submission: On March 12 via api from US — Scanned from US
Effective URL: https://www.typescriptlang.org/
Submission: On March 12 via api from US — Scanned from US
Form analysis
1 forms found in the DOM<form id="search-form" class="search top-nav search-enabled" role="search" aria-live="assertive"><svg fill="none" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg">
<path
d="m10.5 0c.5052 0 .9922.0651042 1.4609.195312.4688.130209.9063.315105 1.3125.554688.4063.239583.7761.52865 1.1094.86719.3386.33333.6276.70312.8672 1.10937s.4245.84375.5547 1.3125.1953.95573.1953 1.46094-.0651.99219-.1953 1.46094-.3151.90625-.5547 1.3125-.5286.77864-.8672 1.11718c-.3333.33334-.7031.61978-1.1094.85938-.4062.2396-.8437.4245-1.3125.5547-.4687.1302-.9557.1953-1.4609.1953-.65104 0-1.27604-.1094-1.875-.3281-.59375-.2188-1.14062-.5339-1.64062-.94534l-6.132818 6.12504c-.098958.0989-.216145.1484-.351562.1484s-.252604-.0495-.351562-.1484c-.0989588-.099-.148438-.2162-.148438-.3516s.0494792-.2526.148438-.3516l6.125002-6.13278c-.41146-.5-.72656-1.04687-.94532-1.64062-.21874-.59896-.32812-1.22396-.32812-1.875 0-.50521.0651-.99219.19531-1.46094s.31511-.90625.55469-1.3125.52604-.77604.85938-1.10937c.33854-.33854.71093-.627607 1.11718-.86719s.84375-.424479 1.3125-.554688c.46875-.1302078.95573-.195312 1.46094-.195312zm0 10c.6198 0 1.2031-.11719 1.75-.35156.5469-.23959 1.0234-.5625 1.4297-.96875.4062-.40625.7265-.88281.9609-1.42969.2396-.54688.3594-1.13021.3594-1.75s-.1198-1.20312-.3594-1.75c-.2344-.54688-.5547-1.02344-.9609-1.42969-.4063-.40625-.8828-.72656-1.4297-.96093-.5469-.23959-1.1302-.35938-1.75-.35938-.61979 0-1.20312.11979-1.75.35938-.54688.23437-1.02344.55468-1.42969.96093s-.72916.88281-.96875 1.42969c-.23437.54688-.35156 1.13021-.35156 1.75s.11719 1.20312.35156 1.75c.23959.54688.5625 1.02344.96875 1.42969s.88281.72916 1.42969.96875c.54688.23437 1.13021.35156 1.75.35156z"
fill="#fff"></path>
</svg><span><span class="algolia-autocomplete" style="position: relative; display: inline-block; direction: ltr;"><input type="search" id="search-box-top" placeholder="Search Docs" aria-label="Search the TypeScript site" class="ds-input"
autocomplete="off" spellcheck="false" role="combobox" aria-autocomplete="list" aria-expanded="false" aria-owns="algolia-autocomplete-listbox-0" dir="auto" style="position: relative; vertical-align: top;">
<pre aria-hidden="true"
style="position: absolute; visibility: hidden; white-space: pre; font-family: "Segoe UI Web (West European)", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: 600; word-spacing: 0px; letter-spacing: normal; text-indent: 0px; text-rendering: auto; text-transform: none;"></pre>
<span class="ds-dropdown-menu" role="listbox" id="algolia-autocomplete-listbox-0" style="position: absolute; top: 100%; z-index: 100; display: none; left: 0px; right: auto;">
<div class="ds-dataset-1"></div>
</span>
</span></span><input type="submit" style="display:none"></form>
Text Content
Skip to main content TypeScript * Download * Docs * Handbook * Community * Playground * Tools in En TYPESCRIPT IS JAVASCRIPT WITH SYNTAX FOR TYPES. TypeScript is a strongly typed programming language that builds on JavaScript, giving you better tooling at any scale. Try TypeScript Now Online or via npm * Editor Checks * Auto-complete * Interfaces * JSX ts const user = { firstName: "Angela", lastName: "Davis", role: "Professor", } console.log(user.name)Property 'name' does not exist on type '{ firstName: string; lastName: string; role: string; }'.2339Property 'name' does not exist on type '{ firstName: string; lastName: string; role: string; }'. ts const user = { firstName: "Angela", lastName: "Davis", role: "Professor", } console.log(user.name)Property 'name' does not exist on type '{ firstName: string; lastName: string; role: string; }'.2339Property 'name' does not exist on type '{ firstName: string; lastName: string; role: string; }'. TypeScript 5.4 is now available WHAT IS TYPESCRIPT? JAVASCRIPT AND MORE TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor. A RESULT YOU CAN TRUST TypeScript code converts to JavaScript, which runs anywhere JavaScript runs: In a browser, on Node.js or Deno and in your apps. SAFETY AT SCALE TypeScript understands JavaScript and uses type inference to give you great tooling without additional code. GET STARTED Handbook Learn the language Playground Try in your browser Download Install TypeScript ADOPT TYPESCRIPT GRADUALLY JavaScript file Apply types to your JavaScript project incrementally, each step improves editor support and improves your codebase. Let's take this incorrect JavaScript code, and see how TypeScript can catch mistakes in your editor. js function compact(arr) { if (orr.length > 10) return arr.trim(0, 10) return arr } No editor warnings in JavaScript files This code crashes at runtime! JavaScript file js // @ts-check function compact(arr) { if (orr.length > 10)Cannot find name 'orr'.2304Cannot find name 'orr'. return arr.trim(0, 10) return arr } Adding this to a JS file shows errors in your editor the param is arr, not orr! JavaScript with TS Check js // @ts-check /** @param {any[]} arr */ function compact(arr) { if (arr.length > 10) return arr.trim(0, 10)Property 'trim' does not exist on type 'any[]'.2339Property 'trim' does not exist on type 'any[]'. return arr } Using JSDoc to give type information Now TS has found a bad call. Arrays have slice, not trim. JavaScript with JSDoc ts function compact(arr: string[]) { if (arr.length > 10) return arr.slice(0, 10) return arr } TypeScript adds natural syntax for providing types TypeScript file DESCRIBE YOUR DATA Describe the shape of objects and functions in your code. Making it possible to see documentation and issues in your editor. ts interface Account { id: number displayName: string version: 1 } function welcome(user: Account) { console.log(user.id) } ts type Result = "pass" | "fail" function verify(result: Result) { if (result === "pass") { console.log("Passed") } else { console.log("Failed") } } TYPESCRIPT BECOMES JAVASCRIPT VIA THE DELETE KEY. ts type Result = "pass" | "fail" function verify(result: Result) { if (result === "pass") { console.log("Passed") } else { console.log("Failed") } } TypeScript file. ts type Result = "pass" | "fail" function verify(result: Result) { if (result === "pass") { console.log("Passed") } else { console.log("Failed") } } Types are removed. js function verify(result) { if (result === "pass") { console.log("Passed") } else { console.log("Failed") } } JavaScript file. TYPESCRIPT TESTIMONIALS First, we were surprised by the number of small bugs we found when converting our code. Second, we underestimated how powerful the editor integration is. TypeScript was such a boon to our stability and sanity that we started using it for all new code within days of starting the conversion. Felix Rieseberg at Slack covered the transition of their desktop app from JavaScript to TypeScript in their blog Read OPEN SOURCE WITH TYPESCRIPT Angular Vue Jest Redux Ionic Probot Deno Vercel Yarn GitHub Desktop LOVED BY DEVELOPERS Voted 2nd most loved programming language in the Stack Overflow 2020 Developer survey TypeScript was used by 78% of the 2020 State of JS respondents, with 93% saying they would use it again. TypeScript was given the award for “Most Adopted Technology” based on year-on-year growth. GET STARTED Handbook Learn the language Playground Try in your browser Download Install TypeScript Made with ♥ in Redmond, Boston, SF & Dublin © 2012-2024 Microsoft Privacy USING TYPESCRIPT * Get Started * Download * Community * Playground * TSConfig Ref * Why TypeScript * Design * Code Samples JavaScriptTypeScript See how TypeScript improves day to day working with JavaScript with minimal additional syntax. JAVASCRIPT ESSENTIALS 1. Hello World 2. Objects and Arrays 3. Functions 4. Code Flow FUNCTIONS WITH JAVASCRIPT 1. Generic Functions 2. Typing Functions 3. Function Chaining WORKING WITH CLASSES 1. Classes 101 2. This 3. Generic Classes 4. Mixins MODERN JAVASCRIPT 1. Async Await 2. Immutability 3. Import Export 4. JSDoc Support EXTERNAL APIS 1. TypeScript with Web 2. TypeScript with React 3. TypeScript with Deno 4. TypeScript with Node 5. TypeScript with WebGL HELPING WITH JAVASCRIPT 1. Quick Fixes 2. Errors Explore how TypeScript extends JavaScript to add more safety and tooling. PRIMITIVES 1. Any 2. Literals 3. Union and Intersection Types 4. Unknown and Never TYPE PRIMITIVES 1. Tuples 2. Built-in Utility Types 3. Nullable Types META-TYPES 1. Conditional Types 2. Discriminate Types 3. Indexed Types 4. Mapped Types LANGUAGE 1. Soundness 2. Structural Typing 3. Type Guards 4. Type Widening and Narrowing LANGUAGE EXTENSIONS 1. Enums 2. Nominal Typing 3. Types vs Interfaces COMMUNITY * Get Help * Blog * GitHub Repo * Community Chat * @TypeScript * Mastodon * Stack Overflow * Web Repo MSG