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

feat: typescript project references #5518

merged 8 commits into from
Apr 9, 2025

Conversation

samdenty
Copy link
Member

@samdenty samdenty commented Apr 2, 2025

This adds project references to the AI SDK codebase.

Improvements

  • Clone codebase, install and start getting intellisense without first running build prior
  • Use find all references to see everywhere something is being used
  • Go to definition now goes to source files
  • Rename symbol across all examples, tests etc.
  • Faster full typecheck 17sec -> 1sec

Possibly breaking changes

Typescript requires the source folders to match output folders, so we would require a bunch of difference tsconfigs with circular dependencies which aren't supported.

So this PR changes the packages with multiple dist folders to instead from:

dist/index.js
anthropic/dist/index.js
...

to

dist/index.js
dist/anthropic/index.js
...

This could be a breaking change if people are depending on the filepath in the package. But if they're importing the package directly, it'll use the import map that i've updated to now use the new format (so should continue working)

Copy link
Collaborator

@lgrammel lgrammel left a comment

Choose a reason for hiding this comment

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

Let's chat on how to best move forward w/ this. Too risky to land on main given the impact and breakages.

* origin/v5:
  Version Packages (canary) (#5625)
  chore (provider): merge rawRequest into request (language model v2) (#5604)
  chore(ui-utils): merge into ai package (#5624)

describe('StreamableValue type', () => {
it('should not contain types marked with @internal after compilation', () => {
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.

this is now not possible to do since we don't have separate dist builds, and it would result in a compile error otherwise

@@ -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

@@ -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

@samdenty samdenty merged commit 861dc20 into v5 Apr 9, 2025
12 checks passed
@samdenty samdenty deleted the samd/project-references branch April 9, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants