sp85
sp853y ago

typescript circular reference error

I'm following the sessions middleware blog post and running into a weird issue. Adding the sessions.ts file from https://github.com/get-convex/convex-helpers/blob/main/convex/sessions.ts to my project gives me the following:
[1] Preparing Convex functions...
[0] wait - compiling...
[0] event - compiled client and server successfully in 66 ms (433 modules)
[1] convex/sessions.ts(88,14): error TS7022: 'create' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
[1] convex/sessions.ts(88,23): error TS2615: Type of property '"sessions:create"' circularly references itself in mapped type 'NameModule<"sessions", typeof import("/Users/me/project/web/convex/sessions")>'.
[1] convex/sessions.ts(88,23): error TS2615: Type of property '"sessions:create"' circularly references itself in mapped type '{ readonly "projects:get": "projects:get"; readonly "projects:list": "projects:list"; readonly "sessions:withSession": never; readonly "sessions:mutationWithSession": never; readonly "sessions:queryWithSession": never; readonly "sessions:create": "sessions:create"; readonly "lib/auth:verifyAuth": never; readonly "us...'.
[1] TypeScript typecheck via `tsc` failed.
[1] To ignore failing typecheck, use `--typecheck=disable`.
[1] Preparing Convex functions...
[0] wait - compiling...
[0] event - compiled client and server successfully in 66 ms (433 modules)
[1] convex/sessions.ts(88,14): error TS7022: 'create' implicitly has type 'any' because it does not have a type annotation and is referenced directly or indirectly in its own initializer.
[1] convex/sessions.ts(88,23): error TS2615: Type of property '"sessions:create"' circularly references itself in mapped type 'NameModule<"sessions", typeof import("/Users/me/project/web/convex/sessions")>'.
[1] convex/sessions.ts(88,23): error TS2615: Type of property '"sessions:create"' circularly references itself in mapped type '{ readonly "projects:get": "projects:get"; readonly "projects:list": "projects:list"; readonly "sessions:withSession": never; readonly "sessions:mutationWithSession": never; readonly "sessions:queryWithSession": never; readonly "sessions:create": "sessions:create"; readonly "lib/auth:verifyAuth": never; readonly "us...'.
[1] TypeScript typecheck via `tsc` failed.
[1] To ignore failing typecheck, use `--typecheck=disable`.
Any pointers?
GitHub
convex-helpers/sessions.ts at main · get-convex/convex-helpers
A collection of useful code to complement the official packages. - convex-helpers/sessions.ts at main · get-convex/convex-helpers
2 Replies
lee
lee3y ago
hi! this is an error you may get if your typescript version is less than our minimum (we're working on the error message, sorry it's very confusing). would it be possible for you to upgrade typescript? i believe the command is npm update typescript
sp85
sp85OP3y ago
that did the trick! thanks!

Did you find this page helpful?