TypeScript and JavaScript
Most templates come in TypeScript and JavaScript. Choose at the language prompt, or pick the id directly: JavaScript ids end in -js, such as bundler-vite-js.
- TypeScript and JavaScript: Game: Starter, Web; Game: Starter, Web, multiplayer; Game: Starter, Discord Activity; Game: Starter, Discord Activity, multiplayer; Bundler: Vite; Bundler: webpack; Bundler: esbuild; Framework: React
- TypeScript only: Extension: Default
- JavaScript only: Bundler: Import map
What changes in JavaScript
The JavaScript versions are generated from the TypeScript ones when create-pixi.js is published, so the code is the same apart from the types. Compared with the TypeScript version, a JavaScript project:
- Has
.jsand.jsxfiles instead of.tsand.tsx, with type annotations removed. - Has no
tsconfig.json, no.d.tsfiles and notypescriptdependency. - Skips
tscin thebuildscript, sobuildonly lints and bundles. - Has no
typescriptplugin or rules in.oxlintrc.json.
Everything else matches: the bundler config, the dev port, and the oxfmt setup.
TypeScript version
The app templates use TypeScript 7 and set noEmit, so tsc only type-checks. Vite, esbuild and esbuild-loader in webpack strip the types when they bundle, which is why build runs tsc as a separate step. The extension template uses the TypeScript version that comes with Extension Scripts.
tsconfig.json turns on strict mode and a few extra checks, including noUnusedLocals and noUnusedParameters. Unused variables and parameters fail the build. Delete them, or prefix an unused parameter with _.
Adding types to a JavaScript project
You can type-check a JavaScript project without converting it. Install TypeScript, add a jsconfig.json or tsconfig.json with "checkJs": true, and describe types with JSDoc comments:
/** @param {import("pixi.js").Sprite} sprite */
function spin(sprite) {
sprite.rotation += 0.1;
}
To move to TypeScript completely, it's usually quicker to create a new project from the TypeScript version of the same template and copy your code across.