Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
162 commits
Select commit Hold shift + click to select a range
6ac0e97
Add standalone TypeScript 7.1 playground
jakebailey Sep 16, 2026
21f6e30
Integrate TS 7.1 playground into website
jakebailey Sep 16, 2026
5b0bda0
Vendor TypeScript 7 compiler for playground
jakebailey Sep 16, 2026
1360e9a
Add vendored TypeScript compiler artifacts
jakebailey Sep 16, 2026
e263e75
Remove internal playground README
jakebailey Sep 16, 2026
b105882
Add TypeScript 7 Monaco LSP support
jakebailey Sep 16, 2026
0bca0ef
Fix TypeScript 7 playground asset URLs
jakebailey Sep 16, 2026
fed0140
Fix playground COI redirect loop
jakebailey Sep 16, 2026
53eca8e
Turn TS7 playground into a project workspace
jakebailey Sep 16, 2026
d67f86b
Improve TypeScript 7 project UX
jakebailey Sep 16, 2026
cdda448
Fix TSConfig validation and saved emit
jakebailey Sep 16, 2026
eb6943b
Add truthful playground loading progress
jakebailey Sep 16, 2026
8639a6a
Cache TypeScript playground assets
jakebailey Sep 16, 2026
65665fd
Enable TS7 semantic editor features
jakebailey Sep 16, 2026
02ee465
Show playground while TypeScript loads
jakebailey Sep 16, 2026
6cfd09a
Clarify playground file tree nesting
jakebailey Sep 16, 2026
0be5f54
Support type queries in JavaScript files
jakebailey Sep 22, 2026
a38d170
Refresh vendored TypeScript WASI compiler
jakebailey Sep 24, 2026
3b18493
Add unified classic TypeScript versions
jakebailey Sep 24, 2026
cdd91f6
Make TS7 playground mobile responsive
jakebailey Sep 24, 2026
dc974e5
Add playground editor navigation history
jakebailey Sep 24, 2026
2c0f368
Add project file deletion
jakebailey Sep 24, 2026
38d49bf
Restore classic Monaco editor features
jakebailey Sep 24, 2026
2155152
Add project-wide Problems panel
jakebailey Sep 24, 2026
151543a
Add automatic package type acquisition
jakebailey Sep 24, 2026
cf26cf6
Integrate playground examples and help
jakebailey Sep 24, 2026
0eb90e5
Vendor the package type acquisition runtime
jakebailey Sep 24, 2026
6bb80a4
Wrap playground controls on tablets
jakebailey Sep 24, 2026
659b863
Add playground workspace layout controls
jakebailey Sep 24, 2026
a7334c0
Simplify playground compiler versions
jakebailey Sep 24, 2026
0ab90f8
Wrap playground code on mobile
jakebailey Sep 24, 2026
6d026df
Contain Monaco on mobile viewports
jakebailey Sep 24, 2026
b98a7e8
Keep Problems above emitted output
jakebailey Sep 24, 2026
85d9fc0
Expand the editor when panels are hidden
jakebailey Sep 24, 2026
653e0f0
Use disclosure controls for output sections
jakebailey Sep 24, 2026
53699e5
Confirm the initial compiler download
jakebailey Sep 24, 2026
16e24e7
Replace the new-file browser prompt
jakebailey Sep 24, 2026
0299dd3
Show the exact compiler version
jakebailey Sep 24, 2026
0a6be8c
Center the compiler download consent
jakebailey Sep 24, 2026
bd61e5f
Version multi-file playground URLs
jakebailey Sep 24, 2026
f5b0cc0
Add inline compiler option overrides
jakebailey Sep 24, 2026
49b8dae
Route legacy examples and handbook links
jakebailey Sep 24, 2026
fb54626
Load acquired package types into the live LSP
jakebailey Sep 24, 2026
5e0e760
Add persisted playground settings
jakebailey Sep 24, 2026
fcfa20f
Replace native playground dialogs
jakebailey Sep 24, 2026
a9e3f53
Replace the native compiler selector
jakebailey Sep 24, 2026
b3daccd
Add a compact playground site shell
jakebailey Sep 24, 2026
a92ba11
Persist editor selections in project links
jakebailey Sep 24, 2026
7de6b82
Restore reflect-metadata run compatibility
jakebailey Sep 24, 2026
c8a5bab
Rename the next-generation playground
jakebailey Sep 25, 2026
e263476
Move Playground v2 to its permanent route
jakebailey Sep 25, 2026
32ca7e0
Improve Playground v2 accessibility
jakebailey Sep 25, 2026
7f0e826
Build the Monaco LSP client from source
jakebailey Sep 30, 2026
80221c2
Patch the Monaco LSP client from git
jakebailey Sep 30, 2026
726e690
Generalize Monaco LSP model ownership
jakebailey Sep 30, 2026
1a332b3
Refresh the Playground v2 compiler
jakebailey Sep 30, 2026
a6d13f3
Include new Corsa API modules
jakebailey Sep 30, 2026
1d8f7c2
Resolve Node builtin package types
jakebailey Sep 30, 2026
86ba926
Make Problems messages copyable
jakebailey Sep 30, 2026
44ffd5e
Show automatic type configuration
jakebailey Sep 30, 2026
8376018
Replace Playground v2 type acquisition
jakebailey Oct 1, 2026
06701a6
Leave the legacy ATA package unchanged
jakebailey Oct 1, 2026
f8d20f6
Leave the legacy playground entry unchanged
jakebailey Oct 1, 2026
41a1f12
Make Playground v2 the default playground
jakebailey Oct 1, 2026
a04a799
Record a release for legacy plugin links
jakebailey Oct 1, 2026
76eebf1
Test compatibility redirects without parsing HTML
jakebailey Oct 1, 2026
bff3dcb
Keep package type acquisition off the startup path
jakebailey Oct 1, 2026
3f1c940
Refresh editor diagnostics after package acquisition
jakebailey Oct 1, 2026
e97206b
Use one compiler diagnostic source in the native editor
jakebailey Oct 1, 2026
1a3fa89
Tighten playground controls and pane layout
jakebailey Oct 1, 2026
14f8b78
Move automatic native compiler work off the UI thread
jakebailey Oct 2, 2026
95822df
Remove the playground's global compiler API
jakebailey Oct 2, 2026
0b4c065
Avoid redundant native program preparation
jakebailey Oct 2, 2026
20c3aa5
Coalesce playground project and selection saves
jakebailey Oct 2, 2026
7830149
Refresh Corsa with the revised WASI package layout
jakebailey Oct 2, 2026
ef43282
Batch acquired package files in the language server
jakebailey Oct 6, 2026
03d31ff
Keep Emit content beside its disclosure header
jakebailey Oct 7, 2026
e31ef51
Start playground projects with one source file
jakebailey Oct 7, 2026
2b62652
Wait for initial compilation before returning type-query hints
jakebailey Oct 7, 2026
0cb1aca
Remove the extra colon from type-query hints
jakebailey Oct 7, 2026
85407d5
Load the compiler from an unchanged runtime package distribution
jakebailey Oct 20, 2026
f014903
Refresh compiler tarballs with the final WASM import path
jakebailey Oct 20, 2026
ea99f00
Modernize the default playground compiler settings
jakebailey Oct 20, 2026
bd19edc
Refresh the vendored WASI compiler
jakebailey Oct 22, 2026
9436be0
Load the published native compiler from a pinned CDN distribution
jakebailey Oct 30, 2026
0da41cf
Keep the new Playground opt-in at /play/v2/
jakebailey Oct 30, 2026
e95f1fe
Keep playground colors readable across appearance changes
jakebailey Oct 30, 2026
b38cb9c
Improve playground keyboard and screen-reader access
jakebailey Oct 30, 2026
d7eaad3
Merge upstream v2 into ts7-playground
jakebailey Oct 30, 2026
c5090b8
Discover and load published native compiler versions
jakebailey Oct 30, 2026
7cd2a26
Document trusted compiler evaluation
jakebailey Oct 30, 2026
850f2fe
Size compiler version controls to their labels
jakebailey Oct 30, 2026
db5f8c1
Keep playground status focused on readiness
jakebailey Oct 30, 2026
0b65c29
Load legacy compiler libraries concurrently with progress
jakebailey Oct 30, 2026
d045f2b
Add emphasis to the new Playground invitation
jakebailey Oct 30, 2026
85a54c4
Preserve native TypeScript comment directives
jakebailey Oct 30, 2026
f6da52f
Parse legacy projects with the selected compiler
jakebailey Oct 30, 2026
a41ed93
Synchronize native editor documents without losing identity
jakebailey Oct 30, 2026
a3d7772
Use explicit Monaco navigation for definition results
jakebailey Oct 30, 2026
a061b7e
Parse list-valued compiler directives as arrays
jakebailey Oct 31, 2026
631d872
Query imported native files in their configured program
jakebailey Oct 31, 2026
0b00e17
Complete legacy standard-library dependency graphs
jakebailey Oct 31, 2026
8474668
Separate configured and inferred legacy language services
jakebailey Oct 31, 2026
495aa8e
Respect legacy compiler completion replacement spans
jakebailey Oct 31, 2026
dbf19ba
Keep native LSP stdin counters safe across wraparound
jakebailey Oct 31, 2026
d8ae22d
Read acquisition versions from actual trailing comments
jakebailey Oct 31, 2026
f9e22f2
Include native program-wide and global diagnostics
jakebailey Oct 31, 2026
58d796c
Reject legacy requests when the compiler worker fails
jakebailey Oct 31, 2026
b189dfe
Reuse declaration models created by concurrent navigation
jakebailey Oct 31, 2026
3e8b085
Synchronize legacy project changes incrementally
jakebailey Oct 31, 2026
08d355b
Track Monaco touch gestures in viewport coordinates
jakebailey Oct 31, 2026
2943255
Let mobile editor swipes continue scrolling the page
jakebailey Oct 31, 2026
7bc312c
Prioritize page swipes past a partially hidden mobile editor
jakebailey Oct 31, 2026
9026bf9
Avoid unintended mobile keyboard activation while browsing
jakebailey Nov 2, 2026
b1c11a0
Follow supported published compiler channels by default
jakebailey Nov 2, 2026
43fa5af
Preserve compiler channel aliases in the new Playground handoff
jakebailey Nov 2, 2026
0756728
Remove build-pinned compiler distribution machinery
jakebailey Nov 2, 2026
6e07e92
Build Playground content from canonical repository sources
jakebailey Nov 2, 2026
a8d25fb
Show toolbar status only for failures
jakebailey Nov 2, 2026
0ee5b4d
Drop the obsolete compiler placeholder from download consent
jakebailey Nov 2, 2026
1186c0c
Supply directory checks to historical compiler file matching
jakebailey Nov 2, 2026
55fa288
Load genuine published historical compiler assets
jakebailey Nov 2, 2026
6a74e3b
Preserve historical settings when trying Playground v2
jakebailey Nov 2, 2026
ee0a2b4
Keep generated TypeScript 6 legacy defaults free of deprecation errors
jakebailey Nov 2, 2026
0e4ffd4
Separate Playground architecture from ATA documentation
jakebailey Nov 2, 2026
749d830
Keep in-app help focused on using the Playground
jakebailey Nov 2, 2026
93041cb
Keep Playground READMEs focused on setup and API constraints
jakebailey Nov 3, 2026
cc6164b
Remove implementation narration from Playground UI copy
jakebailey Nov 3, 2026
ef3c8e4
Sort compiler choices by resolved semantic version
jakebailey Nov 3, 2026
61b6ff2
Align version-index fallback test with semver ordering
jakebailey Nov 3, 2026
7cbc57d
Trim redundant compiler CDN metadata tests
jakebailey Nov 3, 2026
15b4a21
Estimate compiler downloads using sampled compression rates
jakebailey Nov 3, 2026
c32835f
Keep mobile panels stable while browser controls move
jakebailey Nov 3, 2026
b395057
Remove Examples from Playground v2
jakebailey Nov 3, 2026
7d5da22
Use JSX-aware editor language identities
jakebailey Nov 3, 2026
d98f059
Acquire the configured automatic JSX runtime types
jakebailey Nov 3, 2026
0d9ad0a
Remove arbitrary Playground sidebar width caps
jakebailey Nov 3, 2026
f5822f0
Consolidate Playground v2 runtime downloads on UNPKG
jakebailey Nov 3, 2026
a2f0f58
Remove obsolete oldplay redirect routes
jakebailey Nov 3, 2026
a0f0a5e
Support enabling Playground touch input after page load
jakebailey Nov 3, 2026
87a20ba
Clear Playground projects to an empty default page
jakebailey Nov 3, 2026
ed283bb
Support filesystem symlinks in Playground projects
jakebailey Nov 3, 2026
127cd39
Preserve linked project file identity in the UI
jakebailey Nov 3, 2026
887e9a3
Restore project export actions in Playground v2
jakebailey Nov 3, 2026
488af91
Avoid argument limits in Markdown exports
jakebailey Nov 3, 2026
3d13122
Prefer Playground CDN for archived TypeScript releases
jakebailey Nov 3, 2026
ecd9303
Resolve remaining Playground metadata through UNPKG
jakebailey Nov 3, 2026
e60e190
Keep the selected compiler when clearing a Playground
jakebailey Nov 3, 2026
88cb060
Trim Playground v2 export actions
jakebailey Nov 4, 2026
5621c9b
Remove the Playground v2 Help menu
jakebailey Nov 4, 2026
c15b3d4
Group Playground file creation under Add
jakebailey Nov 4, 2026
4dcb63b
Open Playground AST exports in a new tab
jakebailey Nov 4, 2026
1843ae0
Keep Playground toolbar controls together while resizing
jakebailey Nov 4, 2026
9c22e1e
Choose files and symbolic links in the Add dialog
jakebailey Nov 4, 2026
a2c53d6
Align Playground pane and toolbar button styles
jakebailey Nov 4, 2026
a3eddd9
Clarify accepted Playground symlink target paths
jakebailey Nov 4, 2026
0838b87
Keep project aliases from aborting package type acquisition
jakebailey Nov 4, 2026
fca7fbe
Preserve Playground projects through reloads and compiler changes
jakebailey Nov 4, 2026
5be48af
Keep compiler diagnostics on their actual source files
jakebailey Nov 4, 2026
76d536e
Preserve file identity in language-service workspace edits
jakebailey Nov 4, 2026
78b4c3c
Preserve Node18 and Node20 in legacy Playground handoffs
jakebailey Nov 4, 2026
ec51181
Decode escaped Playground share hashes before decompression
jakebailey Nov 4, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
* -text
patches/*.patch -whitespace
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ packages/documentation/output/attribution.json
packages/sandbox/src/releases.json
packages/sandbox/src/release_data.ts
packages/typescriptlang-org/src/lib/documentationNavigation.ts
packages/typescriptlang-org/static/play/v2/
packages/typescriptlang-org/static/play/7/
packages/typescriptlang-org/static/v2/

.idea/

Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"webpack": "^5.105.3"
},
"patchedDependencies": {
"gatsby-remark-shiki-twoslash@3.0.38": "patches/gatsby-remark-shiki-twoslash@3.0.38.patch"
"@vscode/monaco-lsp-client@0.1.0": "patches/@vscode__monaco-lsp-client@0.1.0.patch",
"gatsby-remark-shiki-twoslash@3.0.38": "patches/gatsby-remark-shiki-twoslash@3.0.38.patch",
"monaco-editor-core@0.56.0": "patches/monaco-editor-core@0.56.0.patch"
},
"ignoredBuiltDependencies": [
"@parcel/watcher",
Expand Down
18 changes: 18 additions & 0 deletions packages/playground-v2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Playground v2

The application served at `/play/v2/`.

Run the normal repository bootstrap first. From the repository root:

```sh
pnpm --filter @typescript/playground-v2 dev
pnpm --filter @typescript/playground-v2 typecheck
pnpm --filter @typescript/playground-v2 test
pnpm --filter @typescript/playground-v2 build
```

Compiler code is fetched at runtime, never bundled.
Installed compiler packages are development dependencies for types and tests,
not the default runtime version.

See [package type acquisition](src/ata/README.md) for its API and limitations.
33 changes: 33 additions & 0 deletions packages/playground-v2/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"name": "@typescript/playground-v2",
"private": true,
"type": "module",
"scripts": {
"build": "node scripts/build.mjs",
"dev": "node scripts/build.mjs --serve",
"test": "node scripts/test-ata.mjs && node scripts/smoke-test.mjs",
"typecheck": "node node_modules/typescript/bin/tsc --noEmit && node node_modules/typescript/bin/tsc -p tsconfig.test.json"
},
"dependencies": {
"@bjorn3/browser_wasi_shim": "^0.4.2",
"@fontsource/nunito-sans": "^5.2.6",
"@vscode/monaco-lsp-client": "github:microsoft/monaco-editor#13f0c872dcf352815cc28d92dfff496c9839ea5c&path:/monaco-lsp-client",
"coi-serviceworker": "^0.1.7",
"hack-font": "^3.3.0",
"jsonc-parser": "^3.3.1",
"lz-string": "^1.5.0",
"monaco-editor": "0.56.0",
"monaco-editor-core": "0.56.0",
"reflect-metadata": "^0.2.2",
"semver": "7.7.4",
"vscode-json-languageservice": "^5.3.11",
"vscode-languageserver-textdocument": "^1.0.11"
},
"devDependencies": {
"@typescript/typescript": "npm:typescript@7.1.0-dev.20261030.1",
"@typescript/typescript-wasip1-wasm": "7.1.0-dev.20261030.1",
"@types/semver": "^7.7.1",
"esbuild": "^0.27.3",
"typescript": "*"
}
}
82 changes: 82 additions & 0 deletions packages/playground-v2/scripts/build.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import { context } from "esbuild"
import { cp, mkdir, readFile, rm, writeFile } from "node:fs/promises"
import { dirname, resolve } from "node:path"
import { fileURLToPath } from "node:url"
import { compatibilityHtml, compatibilityPaths, playgroundPath } from "./routes.mjs"

const packageDirectory = resolve(dirname(fileURLToPath(import.meta.url)), "..")
const websiteDirectory = resolve(packageDirectory, "../..")
const outputDirectory = resolve(packageDirectory, "dist")
const websitePlayDirectory = resolve(websiteDirectory, "packages/typescriptlang-org/static/play")
const websiteStaticDirectory = resolve(websitePlayDirectory, "v2")
const compatibilityDirectories = compatibilityPaths.map(path =>
resolve(websiteDirectory, "packages/typescriptlang-org/static", path)
)
const serve = process.argv.includes("--serve")
const playgroundBase = serve ? "/" : process.env.PLAYGROUND_BASE ?? playgroundPath

const editorWorker = fileURLToPath(import.meta.resolve("monaco-editor/editor/editor.worker"))
const coiServiceWorker = fileURLToPath(import.meta.resolve("coi-serviceworker/coi-serviceworker.min.js"))

const indexHtml = (await readFile(resolve(packageDirectory, "src/index.html"), "utf8")).replaceAll(
"__PLAYGROUND_BASE__",
playgroundBase
)

await rm(outputDirectory, { force: true, recursive: true })
await mkdir(outputDirectory, { recursive: true })
await Promise.all([
writeFile(resolve(outputDirectory, "index.html"), indexHtml),
cp(coiServiceWorker, resolve(outputDirectory, "coi-serviceworker.min.js")),
])

const buildContext = await context({
absWorkingDir: packageDirectory,
bundle: true,
conditions: ["browser", "default"],
entryNames: "[name]",
entryPoints: {
main: resolve(packageDirectory, "src/main.ts"),
"editor.worker": editorWorker,
"strada.worker": resolve(packageDirectory, "src/strada.worker.ts"),
"native.worker": resolve(packageDirectory, "src/native.worker.ts"),
"tsgo-lsp.worker": resolve(packageDirectory, "src/tsgo-lsp.worker.ts"),
},
format: "esm",
loader: {
".ttf": "file",
".woff": "file",
".woff2": "file",
},
outdir: outputDirectory,
metafile: true,
platform: "browser",
sourcemap: true,
target: ["es2022"],
})

if (serve) {
await buildContext.watch()
const server = await buildContext.serve({
host: "127.0.0.1",
port: 4173,
servedir: outputDirectory,
})
console.log(`TypeScript Playground v2: http://${server.host}:${server.port}`)
} else {
const result = await buildContext.rebuild()
const compilerInputs = Object.keys(result.metafile.inputs).filter(path =>
/node_modules\/(?:@typescript\/)?typescript(?:-wasip1-wasm)?\//.test(path)
)
if (compilerInputs.length) throw new Error(`Compiler implementation was bundled: ${compilerInputs.join(", ")}`)
await buildContext.dispose()
await rm(websitePlayDirectory, { force: true, recursive: true })
await cp(outputDirectory, websiteStaticDirectory, { recursive: true })
await Promise.all(
compatibilityDirectories.map(async directory => {
await mkdir(directory, { recursive: true })
await writeFile(resolve(directory, "index.html"), compatibilityHtml)
})
)
console.log(`Built Playground v2 in ${outputDirectory}`)
}
14 changes: 14 additions & 0 deletions packages/playground-v2/scripts/routes.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export const playgroundPath = "/play/v2/"
export const compatibilityPaths = ["play/7", "v2"]
export const compatibilityScript = `location.replace(${JSON.stringify(
playgroundPath
)} + location.search + location.hash)`

export const compatibilityHtml = `<!doctype html>
<meta charset="utf-8">
<title>TypeScript Playground v2</title>
<script>
${compatibilityScript}
</script>
<noscript><a href="${playgroundPath}">Continue to TypeScript Playground v2</a></noscript>
`
86 changes: 86 additions & 0 deletions packages/playground-v2/scripts/smoke-test.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import assert from "node:assert/strict"
import { readFile, readdir } from "node:fs/promises"
import { runInNewContext } from "node:vm"
import { compatibilityHtml, compatibilityPaths, compatibilityScript, playgroundPath } from "./routes.mjs"
import { API } from "@typescript/typescript/sync"
import { instantiateWasm, WasmTransport } from "@typescript/typescript/wasm"
import { wasmURL } from "@typescript/typescript-wasip1-wasm"

const wasm = await readFile(wasmURL)
const module = await WebAssembly.compile(wasm)
const instance = await instantiateWasm(module)
const transport = new WasmTransport({ instance, cwd: "/workspace" })
const api = new API({ transport })

try {
assert(compatibilityHtml.includes(`<script>\n ${compatibilityScript}\n</script>`))
for (const path of compatibilityPaths) {
const original = new URL(`https://example.test/${path}/?ts=6.0.3&target=99#code/v2/encoded+project`)
let redirected
runInNewContext(compatibilityScript, {
location: {
search: original.search,
hash: original.hash,
replace(value) {
redirected = value
},
},
})
assert.equal(redirected, `${playgroundPath}${original.search}${original.hash}`)
}

const libListURL = new URL(import.meta.resolve("@typescript/typescript-wasip1-wasm/lib/libFiles.json"))
const libFileNames = JSON.parse(await readFile(libListURL, "utf8"))
assert.deepEqual(
libFileNames,
(await readdir(new URL("./", libListURL))).filter(fileName => /^lib(?:\..+)?\.d\.ts$/.test(fileName)).sort()
)
for (const fileName of libFileNames) {
transport.setFile(`/${fileName}`, await readFile(new URL(fileName, libListURL), "utf8"))
}

const files = {
"/workspace/tsconfig.json": JSON.stringify({
compilerOptions: {
declaration: true,
module: "CommonJS",
strict: true,
target: "ES2022",
},
include: ["./src/**/*"],
}),
"/workspace/src/greet.ts": "export const greet = (name: string) => `Hello, ${name}!`;",
"/workspace/src/index.ts": 'import { greet } from "./greet"; console.log(greet("TS7"));',
}
for (const [fileName, source] of Object.entries(files)) {
transport.setFile(fileName, source)
}

const config = api.readConfigFile("/workspace/tsconfig.json")
assert.equal(config.error, undefined)
const parsed = api.parseJsonConfigFileContent(config.config, {
configFileName: "/workspace/tsconfig.json",
})
assert.deepEqual(parsed.fileNames, ["/workspace/src/greet.ts", "/workspace/src/index.ts"])
const program = api.createProgram(parsed.fileNames, parsed.options, {
projectReferences: parsed.projectReferences,
configFileParsingDiagnostics: parsed.errors,
})
try {
assert.equal(program.getSyntacticDiagnostics().length, 0)
assert.equal(program.getSemanticDiagnostics().length, 0)
const emit = program.emitToString()
assert.equal(emit.emitSkipped, false)
assert.deepEqual(
[...emit.outputFiles.keys()],
["/workspace/src/greet.d.ts", "/workspace/src/greet.js", "/workspace/src/index.d.ts", "/workspace/src/index.js"]
)
assert.match(emit.outputFiles.get("/workspace/src/index.js").text, /require\("\.\/greet"\)/)
} finally {
program.dispose()
}
} finally {
api.close()
}

console.log("TypeScript WASM API smoke test passed")
32 changes: 32 additions & 0 deletions packages/playground-v2/scripts/test-ata.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { build } from "esbuild"
import { spawnSync } from "node:child_process"
import { mkdir, rm } from "node:fs/promises"
import { resolve } from "node:path"

const packageDirectory = resolve(import.meta.dirname, "..")
const testFiles = ["ata.test.mjs", "native-compiler.test.mjs", "lsp-filesystem.test.mjs"].map(name =>
resolve(packageDirectory, "dist", name)
)
await mkdir(resolve(packageDirectory, "dist"), { recursive: true })
try {
await build({
absWorkingDir: packageDirectory,
bundle: true,
conditions: ["browser"],
entryPoints: ["src/ata/ata.test.ts", "src/native-compiler.test.ts", "src/lsp-filesystem.test.ts"],
entryNames: "[name]",
outExtension: { ".js": ".mjs" },
external: ["jsonc-parser"],
format: "esm",
outdir: resolve(packageDirectory, "dist"),
platform: "node",
target: ["es2022"],
})
const result = spawnSync(process.execPath, ["--test", ...testFiles], {
stdio: "inherit",
})
if (result.error) throw result.error
if (result.status !== 0) process.exitCode = result.status ?? 1
} finally {
await Promise.all(testFiles.map(file => rm(file, { force: true })))
}
18 changes: 18 additions & 0 deletions packages/playground-v2/src/ata/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Package type acquisition

`PackageTypeAcquirer.acquire` accepts source files, a parser-backed `discover`
callback, acquisition options, and an abort signal. It returns a complete declaration
snapshot and per-package errors. See [types.ts](types.ts) for the interfaces.

Only declarations and package metadata are downloaded, never package JavaScript.
Packages use their own declarations when available, falling back to
DefinitelyTyped. Node builtins use `@types/node`. Source annotations of the form
`// types: VERSION` select a package version.

The Playground's automatic-types setting disables all acquisition. Otherwise,
the root configuration's `typeAcquisition` options apply; exclusions win.
Inherited acquisition settings and filename-based inference are not supported.
An explicit root `compilerOptions.types` list is preserved.

Only one version of each package can be loaded at a time. DefinitelyTyped
fallback uses its latest version, which may not support historical compilers.
Loading
Loading