TypeScript release

TypeScript 5.1 for JavaScript users

  • Released 1 June 2023
  • Examples run with TypeScript 5.9

TypeScript 5.1 was announced on 1 June 2023. In JavaScript terms it relaxed two rules: a function whose JSDoc says it returns undefined no longer needs a return statement, and a getter and setter can have unrelated types when both are annotated.

Editors gained snippet completions for @param tags in .js and .ts files, JSDoc-heavy files parse faster, and an explicit typeRoots no longer searches parent folders.

At a glance

ReleaseTypeScript 5.1
Released1 June 2023, the day of its announcement on the TypeScript blog
SourceTypeScript 5.1 release notes
ExamplesEvery example runs through TypeScript 5.9.3 when this site is built.
Previous releaseTypeScript 5.0
Next releaseTypeScript 5.2

What changed for JavaScript

Returning undefined without a return statement

Before 5.1, only functions returning void or any could end without return. Now a function with @returns {undefined}, or one passed where a function returning undefined is expected, can too.

reset.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
/** @returns {undefined} */
export function reset() {
  console.log("reset");
}

/** @type {() => undefined} */
export const noop = () => {};
A function typed to return undefined needs no return statement.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": [
    "*.js"
  ]
}

Unrelated getter and setter types

TypeScript 4.3 allowed a setter to accept more than its getter returns, but the getter's type still had to fit the setter. 5.1 drops that rule when both accessors have explicit types: in JavaScript, @returns on the getter and @param on the setter.

label.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
export class Label {
  #text = "";

  /** @returns {{ text: string, length: number }} */
  get value() {
    return { text: this.#text, length: this.#text.length };
  }

  /** @param {string} next */
  set value(next) {
    this.#text = next;
  }
}

const label = new Label();
label.value = "Sale";
console.log(label.value.length);
A getter and a setter with unrelated types, both annotated.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": [
    "*.js"
  ]
}

Snippets for @param

Typing @param in a JSDoc comment offers a completion that fills in the tag for each parameter, in .js files as well as .ts. It is an editor feature; nothing changes for tsc.

typeRoots in module resolution

When an import cannot be resolved the usual way, TypeScript now also looks in the typeRoots folders. And, as a breaking change, an explicit typeRoots no longer falls back to walking up parent folders for node_modules/@types: list every folder you need, including a monorepo root's.

Faster JSDoc parsing

The scanner hands the parser larger pieces of JSDoc comment text, a change the release notes say roughly halves parse time for very large, comment-heavy JavaScript files.

What did not change

An unannotated function with no return is still inferred to return void.

Upgrade notes

From the breaking changes:

  • TypeScript itself needs Node.js 14.17 or later.
  • A config with typeRoots may report TS2688 for types it used to find in a parent folder; add that folder to typeRoots.

Gotchas

  • The relaxed accessor rule needs both types written out; with an inferred getter, reading the property right after assigning through the setter can show the assigned type instead.

Sources

Last reviewed 20 October 2026.