From c300db54ea678276ba8f75ccd7b126b445804fb1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 20 Jul 2026 18:15:45 +0000 Subject: [PATCH 1/2] fix: make typecheck-modules find TS files on Windows Students saw "Test failed (exit code 1)" after all node:test checks passed because typecheck-modules built fast-glob patterns with path.join(), which uses backslashes on Windows and matches nothing. Patch the installed CLI after install to normalize glob paths to forward slashes so directory typechecks work cross-platform. Co-authored-by: Kent C. Dodds --- epicshop/patch-typecheck-modules.js | 50 +++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 epicshop/patch-typecheck-modules.js diff --git a/epicshop/patch-typecheck-modules.js b/epicshop/patch-typecheck-modules.js new file mode 100644 index 0000000..a56d4e6 --- /dev/null +++ b/epicshop/patch-typecheck-modules.js @@ -0,0 +1,50 @@ +import fs from 'node:fs/promises' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const __dirname = path.dirname(fileURLToPath(import.meta.url)) +const cliPath = path.join( + __dirname, + '..', + 'node_modules', + '@kentcdodds', + 'typecheck-modules', + 'cli.js', +) + +const brokenDirectoryPattern = `const pattern = path.join(resolved, '**/*.{ts,tsx}')` +const fixedDirectoryPattern = `const pattern = path + .join(resolved, '**/*.{ts,tsx}') + .split(path.sep) + .join('/')` + +const brokenGlobPattern = `\t\tpatterns.push(resolved)` +const fixedGlobPattern = `\t\tpatterns.push(resolved.split(path.sep).join('/'))` + +let cli = await fs.readFile(cliPath, 'utf8') + +if ( + cli.includes(fixedDirectoryPattern) && + cli.includes(fixedGlobPattern) +) { + console.log('✅ typecheck-modules already patched for Windows globs') + process.exit(0) +} + +if (!cli.includes(brokenDirectoryPattern)) { + throw new Error( + 'Unable to patch typecheck-modules: directory glob pattern not found', + ) +} + +if (!cli.includes(brokenGlobPattern)) { + throw new Error( + 'Unable to patch typecheck-modules: dynamic glob pattern push not found', + ) +} + +cli = cli.replace(brokenDirectoryPattern, fixedDirectoryPattern) +cli = cli.replace(brokenGlobPattern, fixedGlobPattern) + +await fs.writeFile(cliPath, cli) +console.log('✅ Patched typecheck-modules for Windows-safe fast-glob paths') diff --git a/package.json b/package.json index 0092d58..22bcf93 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "type": "module", "scripts": { - "postinstall": "cd ./epicshop && pkgmgr install", + "postinstall": "node ./epicshop/patch-typecheck-modules.js && cd ./epicshop && pkgmgr install", "start": "pkgmgrx --prefix ./epicshop epicshop start", "dev": "pkgmgrx --prefix ./epicshop epicshop start", "test": "pkgmgr run test --silent --prefix playground", From 34e67d18ded10de4da39df6a8b6f4bf6d47eb2a5 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 20 Jul 2026 18:59:54 +0000 Subject: [PATCH 2/2] fix: bump typecheck-modules for Windows glob support Replace the local postinstall patch with @kentcdodds/typecheck-modules@1.0.1, which normalizes fast-glob paths on Windows so typechecks no longer fail after all runtime tests pass. Co-authored-by: Kent C. Dodds --- epicshop/patch-typecheck-modules.js | 50 ----------------------------- package-lock.json | 11 ++++--- package.json | 4 +-- 3 files changed, 9 insertions(+), 56 deletions(-) delete mode 100644 epicshop/patch-typecheck-modules.js diff --git a/epicshop/patch-typecheck-modules.js b/epicshop/patch-typecheck-modules.js deleted file mode 100644 index a56d4e6..0000000 --- a/epicshop/patch-typecheck-modules.js +++ /dev/null @@ -1,50 +0,0 @@ -import fs from 'node:fs/promises' -import path from 'node:path' -import { fileURLToPath } from 'node:url' - -const __dirname = path.dirname(fileURLToPath(import.meta.url)) -const cliPath = path.join( - __dirname, - '..', - 'node_modules', - '@kentcdodds', - 'typecheck-modules', - 'cli.js', -) - -const brokenDirectoryPattern = `const pattern = path.join(resolved, '**/*.{ts,tsx}')` -const fixedDirectoryPattern = `const pattern = path - .join(resolved, '**/*.{ts,tsx}') - .split(path.sep) - .join('/')` - -const brokenGlobPattern = `\t\tpatterns.push(resolved)` -const fixedGlobPattern = `\t\tpatterns.push(resolved.split(path.sep).join('/'))` - -let cli = await fs.readFile(cliPath, 'utf8') - -if ( - cli.includes(fixedDirectoryPattern) && - cli.includes(fixedGlobPattern) -) { - console.log('✅ typecheck-modules already patched for Windows globs') - process.exit(0) -} - -if (!cli.includes(brokenDirectoryPattern)) { - throw new Error( - 'Unable to patch typecheck-modules: directory glob pattern not found', - ) -} - -if (!cli.includes(brokenGlobPattern)) { - throw new Error( - 'Unable to patch typecheck-modules: dynamic glob pattern push not found', - ) -} - -cli = cli.replace(brokenDirectoryPattern, fixedDirectoryPattern) -cli = cli.replace(brokenGlobPattern, fixedGlobPattern) - -await fs.writeFile(cliPath, cli) -console.log('✅ Patched typecheck-modules for Windows-safe fast-glob paths') diff --git a/package-lock.json b/package-lock.json index be769fd..9c9aa60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,7 +17,7 @@ "devDependencies": { "@epic-web/config": "^1.21.3", "@kentcdodds/log-module": "^1.1.1", - "@kentcdodds/typecheck-modules": "^1.0.0", + "@kentcdodds/typecheck-modules": "^1.0.1", "eslint": "^9.39.2", "pkgmgr": "^1.1.1", "prettier": "^3.7.4", @@ -1988,9 +1988,9 @@ } }, "node_modules/@kentcdodds/typecheck-modules": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@kentcdodds/typecheck-modules/-/typecheck-modules-1.0.0.tgz", - "integrity": "sha512-JfgLKH9ho6LZ9u3sHIqUz2U94jQdUp0jniKB0Mm0wJ1qqbR9CE/YKU7yQjBW+W5YODrsPkXH6GLNOx8eL3+89w==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@kentcdodds/typecheck-modules/-/typecheck-modules-1.0.1.tgz", + "integrity": "sha512-ZSUQPPd+jC9ikt57pPRxvzBkWjfKi+/RRq7J0hIluO+lDpcFGAZuSFN6PH0Mkw/P2CvFl1a2zqXE08Awz2rf+A==", "dev": true, "license": "MIT", "dependencies": { @@ -1998,6 +1998,9 @@ }, "bin": { "typecheck-modules": "cli.js" + }, + "engines": { + "node": ">=20" } }, "node_modules/@mdx-js/esbuild": { diff --git a/package.json b/package.json index 22bcf93..364a096 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,7 @@ }, "type": "module", "scripts": { - "postinstall": "node ./epicshop/patch-typecheck-modules.js && cd ./epicshop && pkgmgr install", + "postinstall": "cd ./epicshop && pkgmgr install", "start": "pkgmgrx --prefix ./epicshop epicshop start", "dev": "pkgmgrx --prefix ./epicshop epicshop start", "test": "pkgmgr run test --silent --prefix playground", @@ -57,7 +57,7 @@ "devDependencies": { "@epic-web/config": "^1.21.3", "@kentcdodds/log-module": "^1.1.1", - "@kentcdodds/typecheck-modules": "^1.0.0", + "@kentcdodds/typecheck-modules": "^1.0.1", "eslint": "^9.39.2", "prettier": "^3.7.4", "typescript": "^5.9.3",