Skip to content

Commit bfb2863

Browse files
committed
test: reject declarations in runtime outputs
Scan the complete ESM and CommonJS output trees so supporting declaration files cannot be duplicated unnoticed. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: cb57f94f-69e9-4501-a84e-7661b191ceba
1 parent a7a762a commit bfb2863

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

api/scripts/test-package.cjs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,15 @@ try {
119119
]) {
120120
assert.ok(fs.statSync(path.resolve(installedPackageRoot, target)).isFile(), `${target} must be a file`);
121121
}
122-
for (const duplicateDeclaration of ['./out/esm/main.d.ts', './out/cjs/main.d.ts']) {
123-
assert.ok(
124-
!fs.existsSync(path.resolve(installedPackageRoot, duplicateDeclaration)),
125-
`${duplicateDeclaration} must not duplicate the shared declaration entry point`,
122+
for (const runtimeOutput of ['esm', 'cjs']) {
123+
const runtimeOutputRoot = path.join(installedPackageRoot, 'out', runtimeOutput);
124+
const duplicateDeclarations = fs
125+
.readdirSync(runtimeOutputRoot, { recursive: true })
126+
.filter((entry) => entry.endsWith('.d.ts'));
127+
assert.deepStrictEqual(
128+
duplicateDeclarations,
129+
[],
130+
`${runtimeOutputRoot} must not contain declaration files: ${duplicateDeclarations.join(', ')}`,
126131
);
127132
}
128133

0 commit comments

Comments
 (0)