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
2 changes: 1 addition & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest'
with:
name: site
path: packages/typescriptlang-org/public
path: packages/typescriptlang-org/dist

# Run all the package's tests
- run: pnpm test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/deploy-prod-static.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
- name: Makes the site
run: |
pnpm build-site
cp -r packages/typescriptlang-org/public site
cp -r packages/typescriptlang-org/dist site

- name: Setup Pages
uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,5 @@ packages/typescriptlang-org/src/lib/documentationNavigation.ts
!**/.vscode/extensions.json

*.tsbuildinfo
# astro
.astro/
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
"sharp": "0.28.1"
},
"patchedDependencies": {
"react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825": "patches/react-server-dom-webpack@0.0.0-experimental-c8b778b7f-20220825.patch",
"react-intl@3.12.1": "patches/react-intl@3.12.1.patch",
"gatsby-remark-shiki-twoslash@3.0.38": "patches/gatsby-remark-shiki-twoslash@3.0.38.patch"
"react-intl@3.12.1": "patches/react-intl@3.12.1.patch"
}
},
"jest": {
Expand All @@ -62,7 +60,7 @@
"build-site": "pnpm run --filter=typescriptlang-org build",
"compile": "pnpm run --filter=typescriptlang-org tsc",
"update-snapshots": "pnpm run --filter=typescriptlang-org update-snapshots",
"clean": "pnpm run --filter=typescriptlang-org gatsby clean",
"clean": "pnpm run --filter=typescriptlang-org clean",
"clean-twoslash": "rm -rf packages/.cache/twoslash",
"test": "CI=true pnpm -r run test",
"update-test-snapshots": "CI=true pnpm run --filter=@typescript/twoslash --filter=@typescript/vfs test -u"
Expand Down
4 changes: 2 additions & 2 deletions packages/playground-examples/scripts/copyFiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

const copyDir = join(__dirname, "..", "copy");
const jsonDir = join(__dirname, "..", "generated");
const outDir = join(__dirname, "..", "..", "typescriptlang-org", "static", "js", "examples");
const outDir = join(__dirname, "..", "..", "typescriptlang-org", "public", "js", "examples");

if (!existsSync(outDir)) execSync(`mkdir ${outDir}`);
if (!existsSync(outDir)) execSync(`mkdir -p ${outDir}`);

Check warning

Code scanning / CodeQL

Shell command built from environment values Medium

This shell command depends on an uncontrolled
absolute path
.

Copilot Autofix

AI 2 days ago

In general, the fix is to avoid passing dynamically constructed command strings through a shell. Instead, call the underlying program directly and pass any dynamic values (like paths) as separate arguments, or better, use Node’s own filesystem operations when possible.

For this specific case, the best fix without changing observable functionality is to replace the execSync("mkdir -p ...") invocation with code that creates the directory using Node APIs. Since mkdir -p’s behavior is “create this directory and any missing parents, and don’t error if it already exists,” the direct analogue is fs.mkdirSync(outDir, { recursive: true }), or, since fs-extra is already imported as fse, fse.ensureDirSync(outDir). Using fs-extra keeps the code consistent with the rest of the file.

Concretely:

  • In packages/playground-examples/scripts/copyFiles.js, on line 12, replace if (!existsSync(outDir)) execSync(\mkdir -p ${outDir}`);with a call tofse.ensureDirSync(outDir);`.
  • This removes the shell call entirely, so there is no longer any shell command built from environment values.
  • No new imports are needed; fse is already required from fs-extra.

Suggested changeset 1
packages/playground-examples/scripts/copyFiles.js

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/packages/playground-examples/scripts/copyFiles.js b/packages/playground-examples/scripts/copyFiles.js
--- a/packages/playground-examples/scripts/copyFiles.js
+++ b/packages/playground-examples/scripts/copyFiles.js
@@ -9,7 +9,7 @@
 const jsonDir = join(__dirname, "..", "generated");
 const outDir = join(__dirname, "..", "..", "typescriptlang-org", "public", "js", "examples");
 
-if (!existsSync(outDir)) execSync(`mkdir -p ${outDir}`);
+if (!existsSync(outDir)) fse.ensureDirSync(outDir);
 
 // Move samples
 fse.copySync(copyDir, outDir);
EOF
@@ -9,7 +9,7 @@
const jsonDir = join(__dirname, "..", "generated");
const outDir = join(__dirname, "..", "..", "typescriptlang-org", "public", "js", "examples");

if (!existsSync(outDir)) execSync(`mkdir -p ${outDir}`);
if (!existsSync(outDir)) fse.ensureDirSync(outDir);

// Move samples
fse.copySync(copyDir, outDir);
Copilot is powered by AI and may make mistakes. Always verify output.

// Move samples
fse.copySync(copyDir, outDir);
Expand Down
2 changes: 1 addition & 1 deletion packages/playground-worker/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"private": true,
"scripts": {
"build": "esbuild index.ts --outdir=../typescriptlang-org/static/js/playground-worker --format=esm --target=es2020 --bundle"
"build": "esbuild index.ts --outdir=../typescriptlang-org/public/js/playground-worker --format=esm --target=es2020 --bundle"
},
"dependencies": {
"esbuild": "^0.17.8"
Expand Down
4 changes: 2 additions & 2 deletions packages/playground/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"main": "dist/index.js",
"license": "MIT",
"private": true,
"types": "../../typescriptlang-org/static/js/playground/index.d.ts",
"types": "../../typescriptlang-org/public/js/playground/index.d.ts",
"files": [
"dist"
],
"scripts": {
"//bootstrap": "node scripts/getListOfPluginsFromNPM.js",
"build-fast-test": "esbuild src/index.ts --outdir=../typescriptlang-org/static/js/playground/2 --format=esm --target=es2020 --bundle",
"build-fast-test": "esbuild src/index.ts --outdir=../typescriptlang-org/public/js/playground/2 --format=esm --target=es2020 --bundle",
"build": "tsc",
"test": "jest"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/playground/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"include": ["src"],
"compilerOptions": {
"outDir": "../typescriptlang-org/static/js/playground",
"outDir": "../typescriptlang-org/public/js/playground",
"jsx": "react",
"target": "ES2016",
"module": "AMD",
Expand Down
2 changes: 1 addition & 1 deletion packages/sandbox/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"include": ["src", "src/vendor/lzstring.min.js"],

"compilerOptions": {
"outDir": "../typescriptlang-org/static/js/sandbox",
"outDir": "../typescriptlang-org/public/js/sandbox",
"target": "ES2016",
"module": "AMD",
"lib": ["DOM", "esnext"],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ languages.forEach((lang) => {
JSON.stringify({ options: optionsSummary })
);

const jsonDir = new URL("../../../typescriptlang-org/static/js/json/", import.meta.url);
const jsonDir = new URL("../../../typescriptlang-org/public/js/json/", import.meta.url);
if (!existsSync(jsonDir)) mkdirSync(jsonDir);

// This is used by the tsconfig popups
Expand Down
3 changes: 2 additions & 1 deletion packages/tsconfig-reference/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"moduleResolution": "node",
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"target": "es2019"
"target": "es2019",
"skipLibCheck": true
}
}
23 changes: 13 additions & 10 deletions packages/typescriptlang-org/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ typings/
.cache/
public

# astro
.astro/

# Mac files
.DS_Store

Expand All @@ -73,23 +76,23 @@ schema.json
apollo.config.js

# Build artifacts
static/js/sandbox/
!static/js/sandbox/.gitkeep
static/js/playground/
!static/js/playground/.gitkeep
static/js/examples/
!static/js/examples/.gitkeep
static/js/json
static/js/playground-worker/
public/js/sandbox/
!public/js/sandbox/.gitkeep
public/js/playground/
!public/js/playground/.gitkeep
public/js/examples/
!public/js/examples/.gitkeep
public/js/json
public/js/playground-worker/

.now

# No autogenerated types
src/__generated__/*
# gatsby-plugin-typegen doesn't create this file when CI=true
!src/__generated__/gatsby-types.ts
static/assets/typescript-handbook.epub
static/assets/typescript-handbook.pdf
public/assets/typescript-handbook.epub
public/assets/typescript-handbook.pdf

/src/lib/release-info.json

Expand Down
55 changes: 55 additions & 0 deletions packages/typescriptlang-org/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { defineConfig } from 'astro/config';
import react from '@astrojs/react';
import sitemap from '@astrojs/sitemap';
import { DOMParser } from 'xmldom';

// Polyfill DOMParser for SSR so react-intl can format rich text messages
// (equivalent to the old gatsby-ssr.js polyfill)
globalThis.DOMParser = DOMParser;

export default defineConfig({
site: 'https://www.typescriptlang.org',
integrations: [
react(),
sitemap({
filter: (page) =>
!page.includes('/glossary') && !page.includes('/vo/'),
}),
],
build: {
format: 'file',
},
trailingSlash: 'ignore',
redirects: {
'/Tutorial': '/docs',
'/Handbook': '/docs',
'/samples': '/docs',
'/docs/home.html': '/docs',
'/playground': '/play/',
'/docs/home': '/docs',
'/docs/handbook/writing-declaration-files': '/docs/handbook/declaration-files/introduction.html',
'/docs/handbook/writing-declaration-files.html': '/docs/handbook/declaration-files/introduction.html',
'/docs/handbook/writing-definition-files': '/docs/handbook/declaration-files/introduction.html',
'/docs/handbook/typings-for-npm-packages': '/docs/handbook/declaration-files/publishing.html',
'/docs/tutorial.html': '/docs/',
'/docs/handbook/release-notes': '/docs/',
'/docs/handbook/release-notes/overview': '/docs/',
'/docs/handbook/release-notes/overview.html': '/docs',
'/docs/handbook/react-&-webpack.html': 'https://webpack.js.org/guides/typescript/',
'/docs/bootstrap': '/docs/',
'/docs/handbook/esm-node': '/docs/handbook/modules/reference.html#node16-node18-node20-nodenext',
'/docs/handbook/esm-node.html': '/docs/handbook/modules/reference.html#node16-node18-node20-nodenext',
'/docs/handbook/modules': '/docs/handbook/modules/introduction.html',
'/docs/handbook/modules.html': '/docs/handbook/modules/introduction.html',
'/docs/handbook/module-resolution': '/docs/handbook/modules/theory.html#module-resolution',
'/docs/handbook/module-resolution.html': '/docs/handbook/modules/theory.html#module-resolution',
},
vite: {
resolve: {
dedupe: ['react', 'react-dom'],
},
ssr: {
noExternal: ['react-intl', 'intl-format-cache', 'intl-messageformat', 'intl-messageformat-parser', '@formatjs/intl-utils'],
},
},
});
2 changes: 1 addition & 1 deletion packages/typescriptlang-org/gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ module.exports = {
background_color: `white`,
theme_color: `#3178C6`,
display: `standalone`,
icon: `static/icons/ts-logo-512.png`,
icon: `public/icons/ts-logo-512.png`,
},
},

Expand Down
29 changes: 0 additions & 29 deletions packages/typescriptlang-org/lib/bootup/createPages.ts

This file was deleted.

This file was deleted.

Loading
Loading