Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
21 changes: 18 additions & 3 deletions packages/playground/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,12 +301,27 @@ export const setupPlayground = (
allVersions.forEach((v: string) => {
const li = document.createElement("li")
const a = document.createElement("a")
a.textContent = v
a.href = "#"


// Format version text with release date if available
if (v === "Nightly") {
a.textContent = v
li.classList.add("nightly")
} else {
const versionInfo = sandbox.releaseInfo[v as keyof typeof sandbox.releaseInfo]
if (versionInfo && versionInfo.date) {
const releaseDate = new Date(versionInfo.date)
const formattedDate = releaseDate.toLocaleDateString('en-US', {
year: 'numeric',
month: 'short',
day: 'numeric'
})
a.textContent = `${v} (${formattedDate})`
} else {
a.textContent = v
}
}

a.href = "#"

if (v.toLowerCase().includes("beta")) {
li.classList.add("beta")
Expand Down
25 changes: 25 additions & 0 deletions packages/sandbox/script/downloadReleases.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ const go = async () => {
const releases = await response.json()
const versions = releases.versions.reverse()

// Fetch release dates from npm
const npmResponse = await fetch("https://registry.npmjs.org/typescript")
const npmData = await npmResponse.json()
const releaseDates = npmData.time

// Look through the prereleases to see if the beta and RC are included in the pre-releases
// and add those to the list of versions.
const preReleaseResponse = await fetch("https://playgroundcdn.typescriptlang.org/indexes/pre-releases.json")
Expand Down Expand Up @@ -43,6 +48,13 @@ const go = async () => {
...latestMajMin.values()
].filter(Boolean)

// Build release info object with dates
const releaseInfoEntries = supportedVersions.map(v => {
// Beta and RC versions might not have dates yet
const date = releaseDates[v] || null
return ` "${v}": { version: "${v}", date: ${date ? `"${date}"` : 'null'} }`
}).join(",\n")

const code = `// This is auto-generated by scripts/downloadReleases.js
/** Every prod version **/
export const allReleases = ["${versions.join('", "')}"] as const
Expand All @@ -52,6 +64,19 @@ export const supportedReleases = ["${supportedVersions.join('", "')}"] as const

/** A type of all versions **/
export type ReleaseVersions = "${[possibleBeta, possibleRc, ...versions].join('" | "')}"

/** A type of supported versions **/
export type SupportedReleaseVersions = "${supportedVersions.join('" | "')}"

/** Release information including dates **/
export interface ReleaseInfo {
version: string
date: string | null
}

export const releaseInfo: Record<SupportedReleaseVersions, ReleaseInfo> = {
${releaseInfoEntries}
}
`
const path = join(__dirname, "..", "src", "release_data.ts")
writeFileSync(path, format(code, { filepath: path }), "utf8")
Expand Down
4 changes: 3 additions & 1 deletion packages/sandbox/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "./compilerOptions"
import lzstring from "./vendor/lzstring.min"

import { supportedReleases } from "./release_data"
import { supportedReleases, releaseInfo } from "./release_data"
import { getInitialCode } from "./getInitialCode"
import { extractTwoSlashCompilerOptions, twoslashCompletions } from "./twoslashSupport"
import * as tsvfs from "./vendor/typescript-vfs"
Expand Down Expand Up @@ -389,6 +389,8 @@ export const createTypeScriptSandbox = (
config,
/** A list of TypeScript versions you can use with the TypeScript sandbox */
supportedVersions,
/** Release information including dates for each supported version */
releaseInfo,
/** The monaco editor instance */
editor,
/** Either "typescript" or "javascript" depending on your config */
Expand Down
73 changes: 73 additions & 0 deletions packages/sandbox/src/release_data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// Generated file - do not edit directly
// Run: node generate-release-data.js to regenerate

export type ReleaseVersions = "3.1.8" | "3.2.4" | "3.3.4000" | "3.4.5" | "3.5.3" | "3.6.5" | "3.7.7" | "3.8.3" | "3.9.10" | "4.0.8" | "4.1.6" | "4.2.4" | "4.3.5" | "4.4.4" | "4.5.5" | "4.6.4" | "4.7.4" | "4.8.4" | "4.9.5" | "5.0.4" | "5.1.6" | "5.2.2" | "5.3.3" | "5.4.5" | "5.5.4" | "5.6.3" | "5.7.3" | "5.8.3" | "5.9.3"

export interface ReleaseInfo {
version: string
date: string | null
}

export const releaseInfo: Record<ReleaseVersions, ReleaseInfo> = {
"3.1.8": { version: "3.1.8", date: "2021-02-10T20:39:02.451Z" },
"3.2.4": { version: "3.2.4", date: "2019-01-17T22:31:44.379Z" },
"3.3.4000": { version: "3.3.4000", date: "2019-03-19T23:45:07.488Z" },
"3.4.5": { version: "3.4.5", date: "2019-04-23T17:36:11.732Z" },
"3.5.3": { version: "3.5.3", date: "2019-07-08T22:25:18.351Z" },
"3.6.5": { version: "3.6.5", date: "2020-01-23T19:41:24.260Z" },
"3.7.7": { version: "3.7.7", date: "2021-02-10T20:39:57.410Z" },
"3.8.3": { version: "3.8.3", date: "2020-02-28T22:14:44.636Z" },
"3.9.10": { version: "3.9.10", date: "2021-06-16T22:50:12.465Z" },
"4.0.8": { version: "4.0.8", date: "2021-06-16T23:05:11.358Z" },
"4.1.6": { version: "4.1.6", date: "2021-06-16T23:43:00.385Z" },
"4.2.4": { version: "4.2.4", date: "2021-04-07T18:53:14.660Z" },
"4.3.5": { version: "4.3.5", date: "2021-06-30T23:42:04.770Z" },
"4.4.4": { version: "4.4.4", date: "2021-10-12T19:16:06.762Z" },
"4.5.5": { version: "4.5.5", date: "2022-01-20T18:27:44.268Z" },
"4.6.4": { version: "4.6.4", date: "2022-04-28T21:08:54.918Z" },
"4.7.4": { version: "4.7.4", date: "2022-06-17T18:21:36.833Z" },
"4.8.4": { version: "4.8.4", date: "2022-09-27T19:58:38.001Z" },
"4.9.5": { version: "4.9.5", date: "2023-01-30T21:05:37.231Z" },
"5.0.4": { version: "5.0.4", date: "2023-04-07T17:52:25.635Z" },
"5.1.6": { version: "5.1.6", date: "2023-06-28T23:08:38.755Z" },
"5.2.2": { version: "5.2.2", date: "2023-08-24T16:38:15.233Z" },
"5.3.3": { version: "5.3.3", date: "2023-12-06T19:07:51.067Z" },
"5.4.5": { version: "5.4.5", date: "2024-04-10T14:25:19.427Z" },
"5.5.4": { version: "5.5.4", date: "2024-07-22T23:02:51.857Z" },
"5.6.3": { version: "5.6.3", date: "2024-10-08T22:01:09.783Z" },
"5.7.3": { version: "5.7.3", date: "2025-01-08T19:05:34.766Z" },
"5.8.3": { version: "5.8.3", date: "2025-04-05T00:17:37.851Z" },
"5.9.3": { version: "5.9.3", date: "2025-09-30T21:19:38.784Z" }
}

export const supportedReleases: ReleaseVersions[] = [
"3.1.8",
"3.2.4",
"3.3.4000",
"3.4.5",
"3.5.3",
"3.6.5",
"3.7.7",
"3.8.3",
"3.9.10",
"4.0.8",
"4.1.6",
"4.2.4",
"4.3.5",
"4.4.4",
"4.5.5",
"4.6.4",
"4.7.4",
"4.8.4",
"4.9.5",
"5.0.4",
"5.1.6",
"5.2.2",
"5.3.3",
"5.4.5",
"5.5.4",
"5.6.3",
"5.7.3",
"5.8.3",
"5.9.3"
]