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

Global imports break code in Editor when used via project references #215

Open
patroza opened this issue Jul 29, 2022 · 0 comments
Open

Comments

@patroza
Copy link

patroza commented Jul 29, 2022

Repro

  1. get repo https://github.com/effect-ts-app/boilerplate

    • checkout branch: repro/global-model-imports
  2. in root of repo:

    • yarn
    • yarn build -w
  3. open root repo in vscode

  4. open an api ts file, set vscode typescript version to workspace version

  5. open api/_src/app.ts, spot error
    Argument of type 'ReqHandler<GetHelloWorldRequest, Has, never, unknown, typeof GetHelloWorldRequest, typeof GetHelloWorldResponse>' is not assignable to parameter of type 'RequestHandler<Has, unknown, unknown, unknown, unknown, unknown, unknown, unknown, SupportedErrors>'.
    Types of property 'Request' are incompatible.
    Type 'typeof GetHelloWorldRequest' is not assignable to type 'Request<unknown, unknown, unknown, unknown, unknown, unknown>'.
    Type 'typeof GetHelloWorldRequest' is missing the following properties from type 'ReqResSchemed<unknown, unknown>': Encoder, Model

  6. open packages/client/_src/HelloWorld/Get.ts
    uncomment: // import { Get, Model } from "@effect-ts-app/schema"
    save

  7. see error disappear in app.ts.

Findings:

  • The issue occurs because the dependency is set as a reference to the project using the dependency.
  • In that case, for VSCode it seems to ignore the d.ts and instead considers the .ts source files instead
  • In such case, if the project has not the same globals loaded that the dependency is using, we get this weird issue.
    in my case though I would prefer not to have to load these globals (they are Schema globals that I use extensively in my model packages, but not in my api for instance)

A workaround; if you remove all the project references from api/tsconfig.json, so that the dist is used even in Editor.
but then of course you will have the editor depend on dist d.ts, instead of source files.

For a moment I thought maybe it helps if the global imports are located in the dependency tsconfig.json "types" section, but alas, no dice :)

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

No branches or pull requests

1 participant