Repro
-
get repo https://github.com/effect-ts-app/boilerplate
- checkout branch:
repro/global-model-imports
-
in root of repo:
-
open root repo in vscode
-
open an api ts file, set vscode typescript version to workspace version
-
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
-
open packages/client/_src/HelloWorld/Get.ts
uncomment: // import { Get, Model } from "@effect-ts-app/schema"
save
-
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 :)
Repro
get repo https://github.com/effect-ts-app/boilerplate
repro/global-model-importsin root of repo:
yarnyarn build -wopen root repo in vscode
open an api ts file, set vscode typescript version to workspace version
open
api/_src/app.ts, spot errorArgument 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
open
packages/client/_src/HelloWorld/Get.tsuncomment: // import { Get, Model } from "@effect-ts-app/schema"
save
see error disappear in app.ts.
Findings:
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 thedistis 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 :)