From 8b0f0a35847dac04c34ab941e43c6617a1825d95 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Fri, 10 Apr 2026 22:24:11 -0700 Subject: [PATCH] Typecheck scripts, fix convertFourslash --- .github/workflows/ci.yml | 5 +++++ Herebyfile.mjs | 17 +++++++++++++++++ .../fourslash/_scripts/convertFourslash.mts | 4 ++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 21e70670bc..b148011fd4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -346,10 +346,15 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + - uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0 - uses: ./.github/actions/setup-go + - run: npm ci + - run: go -C ./_tools run ./cmd/checkmodpaths $PWD + - run: npx hereby check:scripts + required: runs-on: ubuntu-latest if: ${{ always() }} diff --git a/Herebyfile.mjs b/Herebyfile.mjs index 031ffd5df3..fd6c76f7e0 100644 --- a/Herebyfile.mjs +++ b/Herebyfile.mjs @@ -854,6 +854,23 @@ export const checkFormat = task({ }, }); +const scriptTsconfigs = [ + "./_scripts/tsconfig.json", + "./internal/fourslash/_scripts/tsconfig.json", + "./internal/lsp/lsproto/_generate/tsconfig.json", +]; + +export const checkScripts = task({ + name: "check:scripts", + description: "Type-checks TypeScript scripts.", + run: async () => { + for (const tsconfig of scriptTsconfigs) { + console.log(`Type-checking ${tsconfig}`); + await $`tsc -p ${tsconfig}`; + } + }, +}); + /** * @param {string} localBaseline Path to the local copy of the baselines * @param {string} refBaseline Path to the reference copy of the baselines diff --git a/internal/fourslash/_scripts/convertFourslash.mts b/internal/fourslash/_scripts/convertFourslash.mts index f5341c73b0..8c1af4a423 100755 --- a/internal/fourslash/_scripts/convertFourslash.mts +++ b/internal/fourslash/_scripts/convertFourslash.mts @@ -1857,7 +1857,7 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string { break; case "organizeImportsTypeOrder": if (!ts.isStringLiteralLike(prop.initializer)) { - return undefined; + throw new Error(`Expected string literal for organizeImportsTypeOrder, got ${prop.initializer.getText()}`); } switch (prop.initializer.text) { case "last": @@ -1870,7 +1870,7 @@ function parseUserPreferences(arg: ts.ObjectLiteralExpression): string { preferences.push(`OrganizeImportsTypeOrder: lsutil.OrganizeImportsTypeOrderFirst`); break; default: - return undefined; + throw new Error(`Unsupported organizeImportsTypeOrder value: ${prop.initializer.text}`); } break; case "autoImportFileExcludePatterns":