# JavaScript type hinting & validation (typescript)

**URL:** https://meta.discourse.org/t/javascript-type-hinting-validation-typescript/395136
**Category:** Developer Guides
**Created:** [February 4, 2026, 10:38am UTC](https://meta.discourse.org/t/javascript-type-hinting-validation-typescript/395136 "2026-02-04T10:38:25Z")
**Posts on this page:** 1
**Showing post:** 1

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [February 4, 2026, 10:38am UTC](https://meta.discourse.org/t/javascript-type-hinting-validation-typescript/395136/1 "2026-02-04T10:38:25Z")

</div>

Discourse ships type information for its JavaScript code. This can provide inline documentation, autocomplete, and other useful IDE features. It can also be used for some basic type validation, using the `@ts-check` directive.

Much of this will be automatically consumed by IDEs with TypeScript/JavaScript support. But for functionality in `.gjs` files, you’ll need some specific configuration and/or IDE plugins.

## Writing TypeScript

Core, themes and plugins can be authored directly in TypeScript. Use a `.ts` extension for plain modules, or `.gts` for Glimmer components with a `<template>` tag. Type syntax is stripped at build time, so no separate compilation step is required. Linting (`@discourse/lint-configs`) and type-checking (`pnpm lint:types`) both understand these files.

## Type tests

Types whose meaning a runtime test can’t capture (a generic’s resolved type, an overload pick, a return type derived from arguments) can be asserted at compile time with [`expect-type`](https://github.com/mmkal/expect-type), in `.ts`/`.gts` files under `frontend/discourse/type-tests/` (e.g. `type-tests/truth-helpers/`). They are checked by `pnpm lint:types` but kept out of the test and production bundles.

## Usage

- **CLI** : Run `pnpm lint:types`

- **VSCode** : Install the [Glint v2](https://marketplace.visualstudio.com/items?itemName=typed-ember.glint2-vscode) extension. This is part of our [recommended config](https://github.com/discourse/discourse/blob/main/.vscode/extensions.json), so you may already have it. If anything isn’t working, you may need to trigger “Restart extension host” from VSCode’s command palette, or restart the IDE.

- **JetBrains** (RubyMine, WebStorm, Intellij, etc.): Install the [EmberExperimental](https://plugins.jetbrains.com/plugin/15499-emberexperimental-js) plugin.

## Troubleshooting

Ensure that you’ve run `pnpm install` recently

## Enabling for a theme or plugin

Official themes/plugins, and the official skeletons, are all wired up for types. To enable it for your own plugin/theme, pull in the latest changes from the relevant skeleton (`package.json`, `tsconfig.json`)

## Live type updates for bundled plugins and themes

If you’re adding or changing core types and need to use those changes immediately in a bundled plugin or theme, use live type updates.

To do so, temporarily change the plugin or theme’s `package.json` to:

```json
{
  "private": true,
  "dependencies": {
    "discourse": "workspace:@discourse/types@*"
  }
}

```

Then run `pnpm install` and start the type watcher with `pnpm types:watch`.

## Enable checking for a file

`.ts` and `.gts` files are always type-checked. For `.js` / `.gjs` files, type-checking is opt-in: add `/** @ts-check */` at the top. For some examples, search Discourse core for `@ts-check`.

## Limitations

We do not provide any guarantees about the accuracy of the types - they’re provided on a best-effort basis. PRs to improve the type documentation in core are welcome.

## Known Issues

- Autocomplete inside `<template>` tags requires complete syntax. For example, if you start typing:

* * *

This document is version controlled - suggest changes [on github](https://github.com/discourse/discourse/blob/main/docs/developer-guides/docs/03-code-internals/27-types.md).

---

_[View the full topic](https://meta.discourse.org/t/javascript-type-hinting-validation-typescript/395136)._
