Non-deterministic types inferred #45364
Labels
Needs Investigation
This issue needs a team member to investigate its status.
Rescheduled
This issue was previously scheduled to an earlier milestone
Milestone
Bug Report
This bug report originates from blitz-js/blitz#2609.
I and other users started seeing
any
in VS Code where a type should be known. It appears quite randomly (at least for me) and disappeared after e.g. modyfing a file. It's quite non-deterministic, it happens only sometimes, and isn't that easy to reproduce consistently, but it does happen often.On the following screenshot you can see the type of
getProjects
function is inferred correctly to be(input: { id?: number }, ctx: Ctx) => Promise<Project>
.However, after making some changes -- e.g. playing with destructuring fields from the second item in
useQuery
result in projects/projectid.ts#L13-- the type in the tooltip becomesany
.I guess, some types are complex and take more time to compute (hence a VS Code lag?). The variable in question is returned from a
pipe
function with 11 overloads – can this be the problem?I tested it with
tsc
in watch mode andnoImplicitAny: true
, and didn't see any errors fromtsc
.However @ugogo reported errors from
tsc
, so this may not be limited to language server.My issues/questions are:
🔎 Search Terms
any, vscode lag, vscode any, inference problem, blitz, zod, prisma, non-deterministic
🕗 Version & Regression Information
Tested with TypeScript 4.3.3, 4.4.0-dev.20210803
⏯ Playground Link
Unfortunately, the problem doesn't occur in the playground.
I'm attaching the link for completeness' sake: https://tsplay.dev/Nd42YN
💻 Code
I'm sorry, but I couldn't show the problem in a minimal code snippet. You can see the Playground for all relevant code, but the surest way to reproduce this would be the following:
git clone git@github.com:blitz-js/blitz.git
and go toblitz
directory.yarn
and build Blitz withyarn build
oryarn dev
.yarn blitz prisma migrate dev
.a. examples/auth/app/projects/queries/getProject.ts
b. examples/auth/app/pages/projects/[projectId]/edit.tsx
any
forproject
after few tries.🙁 Actual behavior
Types in VS Code tooltips are sometimes correct and sometimes
any
in a non-deterministic way.🙂 Expected behavior
The type of the variable is always the same.
The text was updated successfully, but these errors were encountered: