From 8e646ea584ef7b707b857beebf889ebe04e4871a Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Tue, 23 Aug 2022 14:02:50 +0100 Subject: [PATCH] Add static analysis for tsc --strict (#2615) * Initial attempt at CI to annotate new TSC errors * Make tsconfig file valid * enable debug * Specify commit * Fix commit specification * Switch back to main * Tweak permissions * Add strict mode failure * Attempt number two * Fix ts-extra-args * Add static analysis for tsc --strict --- .github/workflows/static_analysis.yml | 35 +++++++++++++++++++++++++++ src/utils.ts | 3 +-- tsconfig.json | 2 +- 3 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/workflows/static_analysis.yml b/.github/workflows/static_analysis.yml index 64bfd4b1b49..33be6c8065b 100644 --- a/.github/workflows/static_analysis.yml +++ b/.github/workflows/static_analysis.yml @@ -54,3 +54,38 @@ jobs: - name: Generate Docs run: "yarn run gendoc" + + tsc-strict: + name: Typescript Strict Error Checker + if: github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + pull-requests: read + checks: write + steps: + - uses: actions/checkout@v3 + + - name: Get diff lines + id: diff + uses: Equip-Collaboration/diff-line-numbers@v1.0.0 + with: + include: '["\\.tsx?$"]' + + - name: Detecting files changed + id: files + uses: futuratrepadeira/changed-files@v3.2.1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + pattern: '^.*\.tsx?$' + + - uses: t3chguy/typescript-check-action@main + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + use-check: true + check-fail-mode: added + output-behaviour: annotate + ts-extra-args: '--strict' + files-changed: ${{ steps.files.outputs.files_updated }} + files-added: ${{ steps.files.outputs.files_created }} + files-deleted: ${{ steps.files.outputs.files_deleted }} + line-numbers: ${{ steps.diff.outputs.lineNumbers }} diff --git a/src/utils.ts b/src/utils.ts index 63e3475b8fb..5dfeffecebe 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -74,8 +74,7 @@ export function decodeParams(query: string): QueryDict { * variables with. E.g. { "$bar": "baz" }. * @return {string} The result of replacing all template variables e.g. '/foo/baz'. */ -export function encodeUri(pathTemplate: string, - variables: Record): string { +export function encodeUri(pathTemplate: string, variables: Record): string { for (const key in variables) { if (!variables.hasOwnProperty(key)) { continue; diff --git a/tsconfig.json b/tsconfig.json index caf28e26391..69c3f0196b5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,6 +12,6 @@ }, "include": [ "./src/**/*.ts", - "./spec/**/*.ts", + "./spec/**/*.ts" ] }