Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: typescript project references #5518

Merged
merged 8 commits into from
Apr 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ jobs:
run: pnpm install --frozen-lockfile

- name: Run TypeScript type check
run: pnpm run type-check
run: pnpm run type-check:full
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

full does it with examples, normal tsconfig does without so it's faster

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ server/dist
public/dist
.turbo
test-results
*.tsbuildinfo
examples/*/build
4 changes: 4 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ To test the package that you're working on, run `pnpm test` in the package folde
You do not need to rebuild your package to test it (only dependencies need to be built).
Some packages like `ai` also have more details tests and watch mode, see their `package.json` for more information.

#### Adding package dependencies

Please run `pnpm update-references` in workspace root to update the `references` section in the `tsconfig.json` file.

### Submitting Pull Requests

We greatly appreciate your pull requests. Here are the steps to submit them:
Expand Down
5 changes: 3 additions & 2 deletions examples/ai-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@
"scripts": {
"test:e2e:all": "vitest run src/e2e/*.test.ts",
"test:file": "vitest run",
"type-check": "tsc --noEmit"
"type-check": "tsc --build"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where will the js files go?

Copy link
Member Author

@samdenty samdenty Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i've added a clean step before running the actual build, so this ensures that before publishes we always have only the correct stuff. Due to microsoft/TypeScript#40431, typescript doesn't yet support noEmit with references. What I could do is instead have a separate dist folder?

with this change you'll have to run build after type-check

},
"devDependencies": {
"@types/node": "20.17.24",
"tsx": "4.19.2",
"typescript": "5.8.3"
"typescript": "5.8.3",
"@vercel/ai-tsconfig": "workspace:*"
}
}
78 changes: 76 additions & 2 deletions examples/ai-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,81 @@
"moduleResolution": "Bundler",
"rootDir": "./src",
"outDir": "./build",
"skipLibCheck": true
"skipLibCheck": true,
"composite": true,
},
"include": ["src/**/*.ts"]
"include": [
"src/**/*.ts"
],
"references": [
{
"path": "../../packages/ai"
},
{
"path": "../../packages/amazon-bedrock"
},
{
"path": "../../packages/anthropic"
},
{
"path": "../../packages/azure"
},
{
"path": "../../packages/cerebras"
},
{
"path": "../../packages/cohere"
},
{
"path": "../../packages/deepinfra"
},
{
"path": "../../packages/deepseek"
},
{
"path": "../../packages/fal"
},
{
"path": "../../packages/fireworks"
},
{
"path": "../../packages/google"
},
{
"path": "../../packages/google-vertex"
},
{
"path": "../../packages/groq"
},
{
"path": "../../packages/luma"
},
{
"path": "../../packages/mistral"
},
{
"path": "../../packages/openai"
},
{
"path": "../../packages/openai-compatible"
},
{
"path": "../../packages/perplexity"
},
{
"path": "../../packages/provider"
},
{
"path": "../../packages/replicate"
},
{
"path": "../../packages/togetherai"
},
{
"path": "../../packages/valibot"
},
{
"path": "../../packages/xai"
}
]
}
5 changes: 3 additions & 2 deletions examples/express/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"scripts": {
"dev": "tsx src/server.ts",
"type-check": "tsc --noEmit"
"type-check": "tsc --build"
},
"dependencies": {
"@ai-sdk/openai": "2.0.0-canary.4",
Expand All @@ -16,6 +16,7 @@
"@types/express": "5.0.0",
"@types/node": "20.17.24",
"tsx": "4.19.2",
"typescript": "5.8.3"
"typescript": "5.8.3",
"@vercel/ai-tsconfig": "workspace:*"
}
}
15 changes: 13 additions & 2 deletions examples/express/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
"moduleResolution": "Bundler",
"rootDir": "./src",
"outDir": "./build",
"skipLibCheck": true
"skipLibCheck": true,
"composite": true
},
"include": ["src/**/*.ts"]
"include": [
"src/**/*.ts"
],
"references": [
{
"path": "../../packages/ai"
},
{
"path": "../../packages/openai"
}
]
}
5 changes: 3 additions & 2 deletions examples/fastify/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@
},
"scripts": {
"dev": "tsx src/server.ts",
"type-check": "tsc --noEmit"
"type-check": "tsc --build"
},
"devDependencies": {
"@types/node": "20.17.24",
"tsx": "4.19.2",
"typescript": "5.8.3"
"typescript": "5.8.3",
"@vercel/ai-tsconfig": "workspace:*"
}
}
15 changes: 13 additions & 2 deletions examples/fastify/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
"moduleResolution": "Bundler",
"rootDir": "./src",
"outDir": "./build",
"skipLibCheck": true
"skipLibCheck": true,
"composite": true
},
"include": ["src/**/*.ts"]
"include": [
"src/**/*.ts"
],
"references": [
{
"path": "../../packages/ai"
},
{
"path": "../../packages/openai"
}
]
}
5 changes: 3 additions & 2 deletions examples/hono/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@
"scripts": {
"dev": "tsx watch src/server.ts",
"curl": "curl -i -X POST http://localhost:8080",
"type-check": "tsc --noEmit"
"type-check": "tsc --build"
},
"devDependencies": {
"@types/node": "20.17.24",
"tsx": "4.19.2",
"typescript": "5.8.3"
"typescript": "5.8.3",
"@vercel/ai-tsconfig": "workspace:*"
}
}
15 changes: 13 additions & 2 deletions examples/hono/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@
"moduleResolution": "Bundler",
"rootDir": "./src",
"outDir": "./build",
"skipLibCheck": true
"skipLibCheck": true,
"composite": true
},
"include": ["src/**/*.ts"]
"include": [
"src/**/*.ts"
],
"references": [
{
"path": "../../packages/ai"
},
{
"path": "../../packages/openai"
}
]
}
5 changes: 3 additions & 2 deletions examples/mcp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"stdio:client": "tsx src/stdio/client.ts",
"custom-transport:build": "tsc src/custom-transport/server.ts --outDir src/custom-transport/dist --target es2023 --module nodenext",
"custom-transport:client": "tsx src/custom-transport/client.ts",
"type-check": "tsc --noEmit"
"type-check": "tsc --build"
},
"dependencies": {
"@ai-sdk/openai": "2.0.0-canary.4",
Expand All @@ -23,6 +23,7 @@
"@types/express": "5.0.0",
"@types/node": "20.17.24",
"tsx": "4.19.2",
"typescript": "5.8.3"
"typescript": "5.8.3",
"@vercel/ai-tsconfig": "workspace:*"
}
}
14 changes: 12 additions & 2 deletions examples/mcp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@
"moduleResolution": "Bundler",
"rootDir": "./src",
"outDir": "./build",
"skipLibCheck": true
"composite": true
},
"include": ["src/**/*.ts"]
"include": [
"src/**/*.ts"
],
"references": [
{
"path": "../../packages/ai"
},
{
"path": "../../packages/openai"
}
]
}
3 changes: 2 additions & 1 deletion examples/nest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3"
"typescript": "^5.1.3",
"@vercel/ai-tsconfig": "workspace:*"
},
"jest": {
"moduleFileExtensions": [
Expand Down
13 changes: 11 additions & 2 deletions examples/nest/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@
"noImplicitAny": false,
"strictBindCallApply": false,
"forceConsistentCasingInFileNames": false,
"noFallthroughCasesInSwitch": false
}
"noFallthroughCasesInSwitch": false,
"composite": true
},
"references": [
{
"path": "../../packages/ai"
},
{
"path": "../../packages/openai"
}
]
}
3 changes: 2 additions & 1 deletion examples/next-fastapi/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"eslint-config-next": "14.2.3",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"typescript": "5.8.3"
"typescript": "5.8.3",
"@vercel/ai-tsconfig": "workspace:*"
}
}
37 changes: 31 additions & 6 deletions examples/next-fastapi/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
{
"compilerOptions": {
"target": "ESNext",
"lib": ["dom", "dom.iterable", "esnext"],
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "esnext",
"moduleResolution": "Bundler",
Expand All @@ -20,9 +23,31 @@
}
],
"paths": {
"@/*": ["./*"]
}
"@/*": [
"./*"
]
},
"composite": true,
"noEmit": true
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"include": [
"next-env.d.ts",
"**/*.ts",
"**/*.tsx",
".next/types/**/*.ts"
],
"exclude": [
"node_modules"
],
"references": [
{
"path": "../../packages/ai"
},
{
"path": "../../packages/react"
},
{
"path": "../../packages/ai"
}
]
}
3 changes: 2 additions & 1 deletion examples/next-google-vertex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"eslint-config-vercel-ai": "workspace:*",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.15",
"typescript": "5.8.3"
"typescript": "5.8.3",
"@vercel/ai-tsconfig": "workspace:*"
}
}
Loading
Loading