#export const api = anyApi;
9 messages · Page 1 of 1 (latest)
Hi @void tinsel. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
api in convex/_generated/api is never actually empty at runtime – it’s just a Proxy over anyApi from convex/server. That proxy always lets you write things like api.foo.bar.baz without throwing; it doesn’t “contain” functions as own properties. [In search of magic; anyApi var]
Because of that:
-
At runtime:
apiis a Proxy →Object.keys(api)orObject.entries(api)is empty, so it looks empty when you inspect it. [How to get schema]- Accessing
api.some.module.funcreturns another Proxy / function reference, not a stored property.
-
At the type level:
api.d.tsdeclaresso the TypeScript type ofdeclare const fullApi: ApiFromModules<{ ... all your convex modules ... }>; export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;apiis built from your modules viaApiFromModulesandFilterApi. [server type aliases; TS secrets]- If your IDE only shows
apiasFilterApi<...>without expanding, that’s an editor/TS config/intellisense limitation, not thatapiis empty. This came up in the “No types in IDE” Discord thread. [No types in IDE]
So “api is empty” usually means one of:
- Runtime inspection (e.g.
Object.entries(api)) – expected to show nothing due to the Proxy design. - Editor not expanding types – but
api.d.tsstill has all your modules/functions listed.
If what you’re seeing is different (e.g. api.d.ts doesn’t list your modules at all), that isn’t covered in the docs here; the sources don’t describe a case where _generated/api is truly empty.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@void tinsel Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@serene magnet like export const api = anyApi;
Let me check the knowledge base for you again. One moment! :books:
export const api = anyApi; in _generated/api.js is expected and does not mean your API is “empty”.
From the docs and stack article:
-
The generated
api.jsjust does:import { anyApi } from "convex/server"; export const api = anyApi; export const internal = anyApi;at runtime. [Generated api.js; Code spelunking]
-
anyApiis a Proxy created bycreateApi()that fabricates function references on the fly when you access properties – it doesn’t have real enumerable properties. So things likeObject.entries(api)will return[], which can make it look empty. [anyApi var; In search of magic]
The types for api live in api.d.ts, not api.js. That file declares:
declare const fullApi: ApiFromModules<{ /* all your convex modules */ }>;
export declare const api: FilterApi<typeof fullApi, FunctionReference<any, "public">>;
so TypeScript knows the full tree of modules and functions even though the runtime object is just anyApi. [Server type aliases; TS secrets]