Skip to content

Commit ccd7612

Browse files
skulidropekclaude
andauthored
fix(app): emit declaration files and fix package type exports for external consumers (#26)
* fix(app): emit declaration files and fix package type exports for external consumers - Add tsconfig.build.json that emits .d.ts only from src/ (excludes examples with test fixture imports) - Change build script to vite build && tsc -p tsconfig.build.json so declarations survive Vite's dist clean - Point exports.types from ./src/index.ts to ./dist/index.d.ts so consumers get compiled declarations - Remove src/ from published files — only dist/ is shipped - Add tests/consumer/ fixture with strict tsconfig and proof-obligation import to pass tsc --noEmit Closes #25 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(tests): remove void operator from consumer fixture (sonarjs/void-use) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(tsconfig): exclude tests/consumer from main typecheck tests/consumer has its own tsconfig.json with paths mapping for @prover-coder-ai/openapi-effect. Including it in the main tsc --noEmit causes TS2307 since the package isn't resolved in the monorepo context. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * fix(consumer): address CodeRabbit review — build before consumer check, add baseUrl - test:consumer now runs tsc -p tsconfig.build.json first so the script works on a clean checkout without a pre-built dist/ - Add baseUrl: "." to tests/consumer/tsconfig.json alongside paths so TypeScript module resolution follows the standard paths protocol Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 564ef0a commit ccd7612

5 files changed

Lines changed: 63 additions & 6 deletions

File tree

packages/app/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66
"main": "dist/index.js",
77
"exports": {
88
".": {
9-
"types": "./src/index.ts",
9+
"types": "./dist/index.d.ts",
1010
"import": "./dist/index.js",
1111
"default": "./dist/index.js"
1212
}
1313
},
1414
"files": [
15-
"dist",
16-
"src"
15+
"dist"
1716
],
1817
"publishConfig": {
1918
"access": "public"
2019
},
2120
"scripts": {
22-
"build": "vite build",
21+
"build": "vite build && tsc -p tsconfig.build.json",
2322
"dev": "vite build --watch",
2423
"lint": "npx @ton-ai-core/vibecode-linter src/",
2524
"lint:tests": "npx @ton-ai-core/vibecode-linter tests/",
2625
"lint:effect": "npx eslint --config eslint.effect-ts-check.config.mjs .",
2726
"lint:types": "./scripts/lint-types.sh",
2827
"check": "tsc --noEmit",
2928
"test": "vitest run",
30-
"typecheck": "tsc --noEmit"
29+
"typecheck": "tsc --noEmit",
30+
"test:consumer": "tsc -p tsconfig.build.json && tsc -p tests/consumer/tsconfig.json"
3131
},
3232
"repository": {
3333
"type": "git",
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// Consumer proof: external project imports createClientEffect and compiles with tsc --noEmit.
2+
// This file must compile cleanly with no local module declaration overrides.
3+
import { createClientEffect } from "@prover-coder-ai/openapi-effect"
4+
5+
type Paths = {
6+
"/health": {
7+
get: {
8+
responses: {
9+
200: {
10+
content: {
11+
"application/json": { ok: boolean }
12+
}
13+
}
14+
}
15+
}
16+
}
17+
}
18+
19+
const client = createClientEffect<Paths>()
20+
21+
// Verify .GET exists and returns something (compile-time only)
22+
client.GET("/health")
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"noEmit": true,
5+
"module": "NodeNext",
6+
"moduleResolution": "NodeNext",
7+
"target": "ES2022",
8+
"lib": ["ES2022", "DOM"],
9+
"verbatimModuleSyntax": true,
10+
"baseUrl": ".",
11+
"paths": {
12+
"@prover-coder-ai/openapi-effect": ["../../dist/index.d.ts"]
13+
}
14+
},
15+
"include": ["index.ts"]
16+
}

packages/app/tsconfig.build.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "../../tsconfig.base.json",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"outDir": "dist",
6+
"declaration": true,
7+
"declarationMap": true,
8+
"emitDeclarationOnly": true,
9+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
10+
"types": ["node"]
11+
},
12+
"include": ["src/**/*"],
13+
"exclude": [
14+
"src/examples/**/*",
15+
"node_modules",
16+
"dist"
17+
]
18+
}

packages/app/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
],
2929
"exclude": [
3030
"dist",
31-
"node_modules"
31+
"node_modules",
32+
"tests/consumer"
3233
]
3334
}

0 commit comments

Comments
 (0)