bluesky-social / atproto

Social networking technology created by Bluesky
Other
6.88k stars 486 forks source link

Schemas that reference another schemas are generated with wrong export/import types #3045

Open pdandradeb opened 2 days ago

pdandradeb commented 2 days ago

Describe the bug

I have a schema named opinion referencing another called topic. The generated code is referencing a Main type that isn't exported which is causing tsc to fail:

Screenshot 2024-11-19 at 15 53 06

Screenshot 2024-11-19 at 16 00 52

To Reproduce

Steps to reproduce the behavior:

  1. git clone git@github.com:pdandradeb/atproto-lex-test.git
  2. cd ./atproto-lex-test && npm install
  3. npm run typecheck

Expected behavior

API files generated without type errors.

Details

Additional context

Before reaching this stage, I learned a lot examining the source of linkat (many thanks to @mkizka). From there I copied postinstall.sh that handles downloading and generating com.atproto.repo schemas that are required by the generated api and the app/global.d.ts file declaring multiformats/cid to "fix" Could not find a declaration file for module 'multiformats/cid' errors.

Is there a better way to handle all that or any other guidance that someone could point me towards? I've also looked into statusphere-example-app but it looks like it faces the same problem:

Screenshot 2024-11-19 at 16 32 56

Screenshot 2024-11-19 at 16 33 20

Thanks in advance!