diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml new file mode 100644 index 000000000..a837e0b1f --- /dev/null +++ b/.github/workflows/CI.yml @@ -0,0 +1,120 @@ +name: CI +on: + pull_request: + branches: + - v2 + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + tests: + strategy: + fail-fast: false + matrix: + os: + - ubuntu-latest + - windows-latest + - macos-latest + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: "18.x" + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 + + - run: pnpm install + + # Grab localizations + - run: pnpm docs-sync pull microsoft/TypeScript-Website-localizations#main 1 + + # Build the packages + - run: pnpm bootstrap + - run: pnpm build + + # Verify it compiles + - run: pnpm build-site + + - uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + if: github.event_name == 'pull_request' && matrix.os == 'ubuntu-latest' + with: + name: site + path: packages/typescriptlang-org/public + + # Run all the package's tests + - run: pnpm test + + # danger for PR builds + - if: github.event_name == 'pull_request' && github.event.pull_request.base.repo.id == github.event.pull_request.head.repo.id && matrix.os == 'ubuntu-latest' + run: "pnpm danger ci" + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - run: | + git add . + if ! git diff --staged --exit-code --quiet; then + echo "This PR is missing some generated changes. Please update locally or merge the patch artifact." + echo "" + git diff --staged + git diff --staged > missing.patch + exit 1 + fi + name: Check for uncommitted changes + id: check-diff + if: github.event_name == 'pull_request' + + - name: Upload diff artifact + if: ${{ failure() && steps.check-diff.conclusion == 'failure' }} + uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882 # v4.4.3 + with: + name: missing.patch + path: missing.patch + + changesets: + name: changesets + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: 'lts/*' + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 + + - run: pnpm install + + - name: Check for missing changesets + run: | + PR_CHANGESETS=$(ls .changeset | (grep -v -E 'README\.md|config\.json' || true) | wc -l) + MAIN_CHANGESETS=$(git ls-tree -r origin/v2 .changeset | (grep -v -E 'README\.md|config\.json' || true) | wc -l) + + # If the PR has no changesets, but main has changesets, assume this is PR is a versioning PR and exit + if [[ $PR_CHANGESETS -eq 0 && $MAIN_CHANGESETS -gt 0 ]]; then + echo "This PR is a versioning PR, exiting" + exit 0 + fi + + # git switch -c changesets-temp + # git checkout origin/v2 -- + pnpm changeset status --since=origin/v2 + + required: + runs-on: ubuntu-latest + if: ${{ always() }} + needs: + - tests + - changesets + + steps: + - name: Check required jobs + env: + NEEDS: ${{ toJson(needs) }} + run: | + ! echo $NEEDS | jq -e 'to_entries[] | { job: .key, result: .value.result } | select(.result != "success")' diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 000000000..99c204627 --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,71 @@ +name: 'Code Scanning - Action' + +on: + push: + branches: + - v2 + pull_request: + branches: + - v2 + schedule: + # ┌───────────── minute (0 - 59) + # │ ┌───────────── hour (0 - 23) + # │ │ ┌───────────── day of the month (1 - 31) + # │ │ │ ┌───────────── month (1 - 12 or JAN-DEC) + # │ │ │ │ ┌───────────── day of the week (0 - 6 or SUN-SAT) + # │ │ │ │ │ + # │ │ │ │ │ + # │ │ │ │ │ + # * * * * * + - cron: '30 1 * * 0' + +permissions: + contents: read + +# Ensure scripts are run with pipefail. See: +# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#exit-codes-and-error-action-preference +defaults: + run: + shell: bash + +jobs: + CodeQL-Build: + # CodeQL runs on ubuntu-latest, windows-latest, and macos-latest + runs-on: ubuntu-latest + if: github.repository == 'microsoft/TypeScript-Website' + + permissions: + # required for all workflows + security-events: write + + steps: + - name: Checkout repository + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + + # Initializes the CodeQL tools for scanning. + - name: Initialize CodeQL + uses: github/codeql-action/init@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + with: + config-file: ./.github/codeql/codeql-configuration.yml + # Override language selection by uncommenting this and choosing your languages + # with: + # languages: go, javascript, csharp, python, cpp, java + + # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). + # If this step fails, then you should remove it and run the build manually (see below). + - name: Autobuild + uses: github/codeql-action/autobuild@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 + + # ℹ️ Command-line programs to run using the OS shell. + # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun + + # ✏️ If the Autobuild fails above, remove it and uncomment the following + # three lines and modify them (or add more) to build your code if your + # project uses a compiled language + + #- run: | + # make bootstrap + # make release + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@662472033e021d55d94146f66f6058822b0b39fd # v3.27.0 diff --git a/.github/workflows/deploy-prod-static.yml b/.github/workflows/deploy-prod-static.yml new file mode 100644 index 000000000..70a83f537 --- /dev/null +++ b/.github/workflows/deploy-prod-static.yml @@ -0,0 +1,70 @@ +name: Deploy to GitHub Pages + +on: + push: + branches: + - v2 + workflow_dispatch: + schedule: + # https://crontab.guru/#0_12_*_*_1 + - cron: "0 12 * * 1" + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. +concurrency: + group: "pages" + cancel-in-progress: false + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + # Fetch the full history, to build attribution.json + fetch-depth: 0 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: "18.x" + + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 + + # Builds the modules, and boostraps the other modules + - name: Build website + run: | + pnpm install + pnpm docs-sync pull microsoft/TypeScript-Website-localizations#main 1 + pnpm bootstrap + pnpm run --filter=typescriptlang-org setup-playground-cache-bust + pnpm build + + - name: Makes the site + run: | + pnpm build-site + cp -r packages/typescriptlang-org/public site + + - name: Setup Pages + uses: actions/configure-pages@983d7736d9b0ae728b81ab479565c72886d7745b # v5 + + - name: Upload artifact + uses: actions/upload-pages-artifact@56afc609e74202658d3ffba0e8f6dda462b719fa # v3 + with: + path: './site' + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-latest + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@d6db90164ac5ed86f2b6aed7e0febac5b3c0c03e # v4 diff --git a/.github/workflows/keepalive.yml b/.github/workflows/keepalive.yml new file mode 100644 index 000000000..3bd232ac0 --- /dev/null +++ b/.github/workflows/keepalive.yml @@ -0,0 +1,21 @@ +name: Keep alive +on: + schedule: + - cron: "0 0 * * *" + +jobs: + keepalive: + runs-on: ubuntu-latest + + permissions: + contents: write + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - run: | + if [[ $(git log --format="%H" --since "50 days" | head -c1 | wc -c) == 0 ]]; then + git config user.email "typescriptbot@microsoft.com" + git config user.name "TypeScript Bot" + git commit --allow-empty -m "Automated commit to keep GitHub Actions active" + git push + fi diff --git a/.github/workflows/publish-packages.yml b/.github/workflows/publish-packages.yml new file mode 100644 index 000000000..4d9052d99 --- /dev/null +++ b/.github/workflows/publish-packages.yml @@ -0,0 +1,41 @@ +name: Publish packages + +on: + push: + branches: [v2] + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +concurrency: ${{ github.workflow }}-${{ github.ref }} + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + with: + fetch-depth: 0 + filter: blob:none + token: ${{ secrets.GITHUB_BOT_TOKEN }} + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: "18.x" + registry-url: "https://registry.npmjs.org/" + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 + + - name: Prepare website v2 + run: | + pnpm install + pnpm bootstrap + pnpm build + + - uses: changesets/action@c8bada60c408975afd1a20b3db81d6eee6789308 # v1.4.9 + with: + publish: pnpm ci:publish + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_BOT_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }} diff --git a/.github/workflows/weekly-stats.yml b/.github/workflows/weekly-stats.yml new file mode 100644 index 000000000..55bfe8238 --- /dev/null +++ b/.github/workflows/weekly-stats.yml @@ -0,0 +1,31 @@ +name: Publish Weekly Stats + +on: + schedule: + # https://crontab.guru/#0_12_*_*_1 + - cron: "0 12 * * 1" + workflow_dispatch: + +permissions: + contents: read + comments: write + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 + - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0 + with: + node-version: "18.x" + + - uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 + + - run: pnpm install + + # Update the site stats + - run: node packages/typescriptlang-org/scripts/updateAppInsightsGitHubIssue.js + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + APP_INSIGHTS_API_KEY: ${{ secrets.APP_INSIGHTS_API_KEY }} + APP_INSIGHTS_ID: ${{ secrets.APP_INSIGHTS_ID }} \ No newline at end of file diff --git a/packages/documentation/copy/en/handbook-v2/Type Manipulation/Generics.md b/packages/documentation/copy/en/handbook-v2/Type Manipulation/Generics.md index 152c61812..bffbc2496 100644 --- a/packages/documentation/copy/en/handbook-v2/Type Manipulation/Generics.md +++ b/packages/documentation/copy/en/handbook-v2/Type Manipulation/Generics.md @@ -449,7 +449,7 @@ interface Consumer { consume: (arg: T) => void; } ``` -Then we can use a `Consumer` where a `Consumer` is expected, because any function that is capable of accepting a `Cat` must also be capable of accepting an `Animal`. +Then we can use a `Consumer` where a `Consumer` is expected, because any function that is capable of accepting an `Animal` must also be capable of accepting a `Cat`. This relationship is called *contravariance*: the relationship from `Consumer` to `Consumer` is the same as the relationship from `U` to `T`. Note the reversal of direction as compared to covariance! This is why contravariance "cancels itself out" but covariance doesn't. diff --git a/packages/documentation/copy/en/release-notes/TypeScript 3.9.md b/packages/documentation/copy/en/release-notes/TypeScript 3.9.md index 57cd8c07c..6b41aad17 100644 --- a/packages/documentation/copy/en/release-notes/TypeScript 3.9.md +++ b/packages/documentation/copy/en/release-notes/TypeScript 3.9.md @@ -138,7 +138,7 @@ Pick `ts-expect-error` if: - you're writing test code where you actually want the type system to error on an operation - you expect a fix to be coming in fairly quickly and you just need a quick workaround -- you're in a reasonably-sized project with a proactive team that wants to remove suppression comments as soon affected code is valid again +- you're in a reasonably-sized project with a proactive team that wants to remove suppression comments as soon as affected code is valid again Pick `ts-ignore` if: diff --git a/packages/typescriptlang-org/scripts/getTypeScriptNPMVersions.js b/packages/typescriptlang-org/scripts/getTypeScriptNPMVersions.js index 826567627..03537e509 100644 --- a/packages/typescriptlang-org/scripts/getTypeScriptNPMVersions.js +++ b/packages/typescriptlang-org/scripts/getTypeScriptNPMVersions.js @@ -110,7 +110,7 @@ const getTypeScriptNPMVersions = async () => { // prettier-ignore let siteReleaseNotesURL = `/docs/handbook/release-notes/typescript-${semver.major(stable)}-${semver.minor(stable)}.html` // prettier-ignore - let releasePostURL = `https://devblogs.microsoft.com/typescript/announcing-typescript-${semver.major(rc)}-${semver.minor(rc)}/` + let releasePostURL = `https://devblogs.microsoft.com/typescript/announcing-typescript-${semver.major(stable)}-${semver.minor(stable)}/` // prettier-ignore let releaseNotesMDPath = `../../documentation/copy/en/release-notes/TypeScript ${semver.major(stable)}.${semver.minor(stable)}.md` // prettier-ignore diff --git a/packages/typescriptlang-org/src/components/layout/TopNav.tsx b/packages/typescriptlang-org/src/components/layout/TopNav.tsx index 6074d31c6..02036b440 100644 --- a/packages/typescriptlang-org/src/components/layout/TopNav.tsx +++ b/packages/typescriptlang-org/src/components/layout/TopNav.tsx @@ -104,7 +104,7 @@ export const SiteNav = (props: Props) => {
  • {i("nav_documentation_short")}
  • {i("nav_handbook")}
  • {i("nav_community")}
  • -
  • {i("nav_playground")}
  • +
  • {i("nav_playground")}
  • {i("nav_tools")}
  • diff --git a/packages/typescriptlang-org/src/copy/en/index2.ts b/packages/typescriptlang-org/src/copy/en/index2.ts index a6f2eb981..c5ed1049d 100644 --- a/packages/typescriptlang-org/src/copy/en/index2.ts +++ b/packages/typescriptlang-org/src/copy/en/index2.ts @@ -28,7 +28,7 @@ export const indexCopy = { index_2_what_is_js_copy: `TypeScript adds additional syntax to JavaScript to support a tighter integration with your editor. Catch errors early in your editor.`, index_2_trust: "A Result You Can Trust", - index_2_trust_copy: `TypeScript code converts to JavaScript, which runs anywhere JavaScript runs: In a browser, on Node.js or Deno and in your apps.`, + index_2_trust_copy: `TypeScript code converts to JavaScript, which runs anywhere JavaScript runs: In a browser, on Node.js, Deno, Bun and in your apps.`, index_2_scale: "Safety at Scale", index_2_scale_copy: `TypeScript understands JavaScript and uses type inference to give you great tooling without additional code.`,