TS 3.8

Type-Only Imports and Export

--isolatedModules

import type { SomeThing } from "./some-module.js"

export type { SomeThing }
import type { Component } from "react"

interface ButtonProps {
    // ...
}

class Button extends Component<ButtonProps> {
    //               ~~~~~~~~~
    // error! 'Component' only refers to a type, 
    // but is being used as a value here.
}

ECMAScript Private Fields (stage #3)

class Person {
    #name: string

    constructor(name: string) {
        this.#name = name;
    }

    greet() {
        console.log(`Hello, my name is ${this.#name}!`);
    }
}

let jeremy = new Person("Jeremy Bearimy");

jeremy.#name
//     ~~~~~
// Property '#name' is not accessible outside class 'Person'
// because it has a private identifier.

export * as ns Syntax

import * as utilities from "./utilities.js"

export { utilities }
export * as utilities from "./utilities.js"

було

новий сахар

Top-Level await

const response = await fetch("...");
const greeting = await response.text();

export { response, greeting };

es2020 for target and module

  • optional chaining
  • nullish coalescing
  • export * as ns
  • dynamic import(...) syntax
  • bigint

JSDoc Property Modifiers

  • @public,
  • @private
  • @protected
  • @readonly
// @ts-check

class Foo {
  constructor() {
    /** @private */
    this.stuff = 100;
  }

  printStuff() {
    console.log(this.stuff);
  }
}

new Foo().stuff;
//        ~~~~~
// error! Property 'stuff' is private
// and only accessible within class 'Foo'.

new Foo().stuff++;
//        ~~~~~
// Cannot assign to 'stuff' because it is
// a read-only property.

“Fast and Loose” Incremental Checking

--assumeChangesOnlyAffectDirectDependencies

 

 

Visual Studio code base recompile time 14s - 1s

Future

TS 3.8

By Kolya Koval

TS 3.8

  • 268