Skip to content

Commit 2f50562

Browse files
fix(api): Isolate API package validation consumers from ambient type definitions (#1800)
## Related Issue Fixes #1799 ## Changes Proposed * **[API Test Configurations]**: Configured `"types": ["node", "vscode"]` and `"typeRoots": ["../node_modules/@types"]` in `api/test/tsconfig.modern.json` and `api/test/tsconfig.legacy.json` to prevent `tsc` from traversing parent directories for ambient type definitions. * **[Test Package Runner]**: Updated `api/scripts/test-package.cjs` to resolve `typescript/bin/tsc` dynamically via `createRequire` instead of hardcoding `packageRoot/node_modules/typescript/bin/tsc`. * **[API Package Scripts]**: Added `"test": "npm run test:package"` to `api/package.json` so standard `npm test` runs package validation. ## How Has This Been Tested? Please describe the tests that you ran to verify your changes. * [x] Test A: `npm --prefix api run test:package` completed with 0 errors (modern and legacy consumers verified). * [x] Test B: `npm --prefix api test` ran successfully. * [x] Test C: Root unit tests (`npm run unittest`) passed with 2,411 passing tests. * [x] Test D: Root linter (`npm run lint`) passed with 0 errors/warnings. * [x] Test E: TypeScript compilation (`npm run compile-tests`) succeeded with 0 errors. ## Checklist - [x] My code follows the style guidelines of this project - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] My changes generate no new warnings
1 parent e4ab62b commit 2f50562

4 files changed

Lines changed: 9 additions & 3 deletions

File tree

‎api/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
"compile:esm": "tsc -b ./tsconfig.esm.json && mve out/esm/main.js out/esm/main.mjs && node -e \"require('fs').writeFileSync('out/esm/package.json', '{\\\"type\\\":\\\"module\\\"}')\"",
4747
"compile:cjs": "tsc -b ./tsconfig.cjs.json && mve out/cjs/main.js out/cjs/main.cjs",
4848
"clean": "node -e \"const fs = require('fs'); fs.rmSync('./out', { recursive: true, force: true });\"",
49+
"test": "npm run test:package",
4950
"test:package": "node ./scripts/test-package.cjs"
5051
},
5152
"devDependencies": {

‎api/scripts/test-package.cjs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ try {
5555
testRoot,
5656
);
5757

58-
const typescriptCli = path.join(packageRoot, 'node_modules', 'typescript', 'bin', 'tsc');
58+
const packageRequire = createRequire(path.join(packageRoot, 'package.json'));
59+
const typescriptCli = packageRequire.resolve('typescript/bin/tsc');
5960
const fixtureRoot = path.join(packageRoot, 'test');
6061

6162
for (const consumer of [

‎api/test/tsconfig.legacy.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"moduleResolution": "Node",
66
"noEmit": true,
77
"strict": true,
8-
"skipLibCheck": false
8+
"skipLibCheck": false,
9+
"types": ["node", "vscode"],
10+
"typeRoots": ["../node_modules/@types"]
911
},
1012
"include": ["consumer.ts"]
1113
}

‎api/test/tsconfig.modern.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
"moduleResolution": "NodeNext",
66
"noEmit": true,
77
"strict": true,
8-
"skipLibCheck": false
8+
"skipLibCheck": false,
9+
"types": ["node", "vscode"],
10+
"typeRoots": ["../node_modules/@types"]
911
},
1012
"include": ["consumer.ts"]
1113
}

0 commit comments

Comments
 (0)