Your toys, our sandbox

The new TypeScript Playground allows people to hook into the Playground and extend it in ways in which the TypeScript team don't expect.

The sidebar of the Playground uses the same plugin infrastructure as external plugins, so you have the same level of access as the playground to build interesting projects.

Playground plugins are built via the DOM API and an expansive Design System, however, you're free to use a framework like React or Svelte at runtime.

 

Getting started is easy, we have a plugin template, and the Playground has a dev-mode for hooking directly to your local server, so you don't need to run a copy of the TypeScript website to have a working development environment.

There is a repo of sample plugins at microsoft/TypeScript-Playground-Samples and there are many existing open source plugins to look at too: Presentation Mode, Clippy TSQuery, Collaborate and Transformer which are available by default for you to investigate and understand.

If you have questions as you are working on your plugin, ask in the TypeScript Community Discord. When it is polished, ship it to the npm registry and it will make its way into the plugins sidebar.

Screenshot of the playground showing the plugins tab

Quick Tutorial

You need about 5 minutes, Node.js, yarn and Firefox/Edge or Chrome.

Step 1: Use the template to bootstrap: yarn create typescript-playground-plugin playground-my-plugin

Step 2: Run yarn start in the new repo, to start up the local dev server

Step 3: Open the playground in your browser, click "Options" and enable "Connect to localhost:5000/index.js"

Step 4: Refresh, and see the new tab. That's your plugin up and running

 

That's all the pieces working in tandem, now you can make changes to the template and build out your plugin. The plugin in dev mode will always become forefront when connected, so you can re-load without a lot of clicks. To understand the template's technology, read the CONTRIBUTING.md

Alternatives

There are community-run templates for Playground plugins which bootstrap your plugin with well-known view libraries:

They have their own up-to-date documentation in their READMEs.