Opens profile photo
Follow
Click to Follow typescript
TypeScript
@typescript
TypeScript is a language for application-scale JavaScript development. It's a typed superset of JavaScript that compiles to plain JavaScript.
Redmond, WAtypescriptlang.orgJoined September 2012

TypeScript’s Tweets

Pinned Tweet
TypeScript 5.1 is now out! Now with: - smarter checks for undefined-returning functions - no restrictions between getter/setter types - better checks against JSX tags - linked editing for JSX - @⁠param snippets - new speed-ups Read up more on our blog!
14
1,658
Today the TypeScript team is releasing a new VS Code extension named Deopt Explorer! This tool can help find polymorphism and deoptimizations in your code, and it's already helped us speed up TypeScript itself. Check out what we've built!
29
3,224
TypeScript 5.1 Beta is now available to try, with - smarter checks for undefined-returning functions - no restrictions between getter/setter types - customizable tag checks for JSX libraries - linked editing for JSX - @⁠param snippets and more!
12
907
Modeled as throughput, TypeScript would be 25% faster, or 1.25x faster to compile VS Code. We chose to use proportion of time instead of increases in throughput since we felt it was a more straightforward calculation.
1
52
Show this thread
As a clarification on this chart - these are proportions of build times relative to TypeScript 4.9. So TypeScript 5.0 takes 80% of the time that TypeScript 4.9 took to build VS Code - a reduction of 20%.
1
39
Show this thread
Speaking of literal types - every enum member now acts kind of like a literal type. This is way safer, and pushes us to be tidy and consistent. 🤓
enum E {
    A = 42,
}

// still works
let fine: E = 42;

// ❌ now an error
let oops: E = 43;
2
113
Show this thread
We're pretty sure you love coding with TypeScript - but just in *case*, we added a new feature to our code-completions. If you write a 'switch' statement and you're using literal types, we'll scaffold out all your 'case's automagically. 🪄
type Fruit =
    | { kind: "apple" }
    | { kind: "orange" }
    | { kind: "banana" }

function nom(fruit: Fruit) {
    switch (fruit.kind) {
        // Completions here now include a snippet
        // which fills in cases for the strings "apple", "orange", and "banana".
    }
}
GIF
7
397
Show this thread
Does your linter fight with your editor? We're lovers, not fighters. Let's all get along. ☮️✌️ TypeScript 5.0 is smarter about respecting upper/lower-casing in already-sorted imports.
2
61
Show this thread
If you're a library author, maybe you've told your users to write 'as const' when they call a function. With 'const' type parameters, you can hint which values should get literal & read-only types.
declare function frozen<const T>(x: T): T;

// inferred type is 'readonly ["elsa", "anna", "olaf"]'
let itSnow = frozen([
   "elsa", "anna", "olaf"
]);
3
117
Show this thread
TypeScript 5.0 brings '--moduleResolution bundler' to model how most modern bundlers and loaders work. It understands classic Node-style resolution while respecting rules for 'exports', 'imports', etc. in your dependencies.
To model how bundlers work, TypeScript now introduces a new strategy: `--moduleResolution bundler`.

```
{
    "compilerOptions": {
        "target": "esnext",
        "moduleResolution": "bundler"
    }
}
```

If you are using a modern bundler like Vite, esbuild, swc, Webpack, Parcel, and others that implement a hybrid lookup strategy, the new `bundler` option should be a good fit for you.
2
110
Show this thread
If you thought TypeScript 4.9 was a satisfying release... 5.0 will do it again by bringing support for /** @⁠satisfies */ to checked JavaScript files! Works the same as our recent 'satisfies' operator in TypeScript files.
/**
 * @satisfies {Record<string, (e: Event) => void>}
 */
export let eventHandlers = {
    // type of 'e' is inferred as 'Event'
    click: (e) => {
        e.preventDefault();
    },
    scroll: (e) => {

    },
};

// ✅ works
eventHandlers.click(new Event("click"));

// ❌ error
eventHandlers.clock(new Event("click"));
2
93
Show this thread
Ever gotten into an argument about decorating? Now you can decorate without any red flags. 🚩🚩🚩🚩 TypeScript 5.0 ships the latest version of decorators! ✨ Use them without setting --experimentalDecorators 🧪.
class Greeter {
    message: string;
    constructor(message: string) {
        this.message = message;
    }

    @bound
    greet() {
        console.log(this.message);
    }
}

const greeter = new Greeter("sup?");
const greet = greeter.greet;

greet();
/**
 * Ensures a method is bound to every instance.
 */
function bound(method: Function, context: ClassMethodDecoratorContext<any>) {
    if (context.private) {
        throw new Error("Cannot bind private methods.");
    }
    context.addInitializer(function (this) {
        this[context.name] = method.bind(this);
    });
}
1
107
Show this thread
We'll make this one fast: TypeScript's now way speedier. You can expect at anywhere from 10%-20% of your compile times to disappear with TypeScript 5.0!
Chart of build/run times TypeScript 5.0 relative to TypeScript 4.9:

material-ui docs build time: 90%
Playwright build time: 88%
tsc startup time: 87%
tsc build time: 87%
Outlook Web build time: 82%
VS Code build time: 80%
2
135
Show this thread
Want to know what's new in TypeScript 5.0 at a glance? Here's a thread about what's packed into this release that makes it great. 🧵
Quote Tweet
TypeScript 5.0 is here! 🎉🎉 Learn about what's new and try it today! devblogs.microsoft.com/typescript/ann
Show this thread
2
132
Show this thread
Our Release Candidate for TypeScript 5.0 is out now! Try our new decorators, better modes for modules in Node & bundlers, new inference tools for library authors, new JSDoc tags, and some nice speedups! Help us shape the 5.0 release to be perfect!
11
484
TypeScript 5.0 Beta is now out to try! 🚀 Now with ES decorators, better modes for modules in Node & bundlers, new inference tools for library authors, JSDoc support - and last but not least, some great speed and size improvements!
31
1,580
TypeScript 4.9 has landed, and it's a release that's guaranteed to satisfy! Now bringing ✅ A new 'satisfies' operator ✅ Improved narrowing with 'in' ✅ More efficient file-watching ✅ Better tools import clean-up and more! Read up now!
21
1,279
TypeScript 4.8 is here! Now with ✅ Improved narrowing and inference ✅ Primitive-parsing from template string types ✅ --incremental/--watch perf improvements ✅ Lots of new correctness checks and more! Read up and get it now!
26
839
TypeScript 4.7 is now out, bringing ✅ Support for ES modules in Node.js ✅ Improved inference and narrowing ✅ More powerful conditional types ✅ Go to Source Definition ✅ Smarter Organize Imports and more! Try it out today!
13
1,486
The Types as Comments proposal means that browsers could run TypeScript-checked code directly, (even though they wouldn't do any type-checking). That means faster iteration with all the type-checking and editing experience you know and love today.
5
331
Show this thread