# TypeScript 7 WASM

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Release][release-src]][release-href]

**Unofficial** WebAssembly (WASM) distribution of [TypeScript 7](https://github.com/microsoft/typescript-go), automatically built via GitHub Actions. Package versions and npm dist-tags mirror the official [`typescript`](https://www.npmjs.com/package/typescript) package (`>= 7`).

> This is a fork of the original [sxzz/tsgo-wasm](https://github.com/sxzz/tsgo-wasm) repository.

Use this version if your operating system or architecture is not supported by the native build, or if you need to run it in browsers.

Download the latest binaries from the [Releases page](https://github.com/wasmbinaries/typescript/releases).

Read more about the TypeScript 7 [here](https://devblogs.microsoft.com/typescript/typescript-native-port/)!

> [!WARNING]
> This is **NOT** an official distribution from the TypeScript official team, but all binaries are built directly from the official source code without any modifications via GitHub Actions.

## Usage

```bash
npm install @webassembly/typescript

npx tsc -v
# Version 7.0.0-dev.20250519
```

## 🧯 Safety

The binaries are built through GitHub Actions using source code checked out on demand directly from the official
[`microsoft/typescript-go`](https://github.com/microsoft/typescript-go) repository (at the `typescript/v<version>` tag),
without any modifications. The exact upstream commit each release was built from is recorded in `buildInfo.commit`
inside the published `package.json` and in the GitHub release notes.
The complete build workflow is transparent and open-source, available for inspection [here](./.github/workflows/release.yml).

We understand security concerns regarding unofficial binaries.
For additional peace of mind, you're welcome to fork this repository and execute the build workflow yourself.

## 🛠️ Development

The entire release pipeline lives in [`scripts/release.ts`](./scripts/release.ts). It resolves the target
`typescript` versions (`>= 7`), skips any already published to `@webassembly/typescript`, and for each missing
version clones typescript-go at the matching tag, builds the WASM binary with [GoReleaser](https://goreleaser.com),
sets the package version + `buildInfo`, publishes to npm, and purges the jsDelivr cache.

Requirements: [Go](https://go.dev), [Node.js](https://nodejs.org), [pnpm](https://pnpm.io) and
[GoReleaser](https://goreleaser.com). Provide an `NPM_TOKEN` (consumed by [`.npmrc`](./.npmrc)) to publish.

```bash
pnpm i

# Dry run: build with `goreleaser --snapshot`, no tagging/publishing.
pnpm release:dry

# Mirror the current typescript dist-tags (latest/rc/next) that are missing.
pnpm release

# Release one explicit version.
pnpm release --version 7.0.2
```

## Credits

Thanks to Claude 3.7 Sonnet for helping me build the GitHub Actions workflow.

## License

The TypeScript project and this project both are licensed under the [Apache License 2.0](./LICENSE).

<!-- Badges -->

[npm-version-src]: https://img.shields.io/npm/v/@webassembly/typescript.svg
[npm-version-href]: https://npmjs.com/package/@webassembly/typescript
[npm-downloads-src]: https://img.shields.io/npm/dm/@webassembly/typescript
[npm-downloads-href]: https://www.npmcharts.com/compare/@webassembly/typescript?interval=30
[release-src]: https://github.com/wasmbinaries/typescript/actions/workflows/release.yml/badge.svg
[release-href]: https://github.com/wasmbinaries/typescript/actions/workflows/release.yml
