void
void•2y ago

Exported query missing type annotations when building convex in another directory other than root

I have a query that looks like this (src/convex/steam.ts):
export const listAll = query(async ({ db }) => {
const steamAccounts = await db.query('steamAccounts').collect();
return Promise.all(
steamAccounts.map(async (steamAccount) => {
const discordUser = await db.get(steamAccount.discordUser);
const server = (await db.get(discordUser!.server))!;
return {
server,
discordUser,
steamAccount
};
})
);
});
export const listAll = query(async ({ db }) => {
const steamAccounts = await db.query('steamAccounts').collect();
return Promise.all(
steamAccounts.map(async (steamAccount) => {
const discordUser = await db.get(steamAccount.discordUser);
const server = (await db.get(discordUser!.server))!;
return {
server,
discordUser,
steamAccount
};
})
);
});
When building with my convex.json specifying src/convex of my directory, tsc fails for this reason:
src/convex/steam.ts:70:14 - error TS2742: The inferred type of 'listAll' cannot be named without a reference to '../../node_modules/convex/dist/types/server/registration'. This is likely not portable. A type annotation is necessary.

70 export const listAll = query(async ({ db }) => {
~~~~~~~


Found 1 error in src/convex/steam.ts:70
src/convex/steam.ts:70:14 - error TS2742: The inferred type of 'listAll' cannot be named without a reference to '../../node_modules/convex/dist/types/server/registration'. This is likely not portable. A type annotation is necessary.

70 export const listAll = query(async ({ db }) => {
~~~~~~~


Found 1 error in src/convex/steam.ts:70
2 Replies
void
voidOP•2y ago
weirder thing is if i run tsc twice, it seems like nothing is wrong and i can execute my built node project fine 👀
ballingt
ballingt•2y ago
thanks for reporting, I can reproduce this every time by disabling incremental TypeScript compilation It looks like adding these two fields to your tsconfig.json solves the issue, (because the file your tsconfig.json inherits from sets them to true) resolves the issue
"declaration": false,
"declarationMap": false,
"declaration": false,
"declarationMap": false,
so I wonder if this has to do with not making certain types public which could be. We'll look into it, but hopefully this unblocks you. I'm not sure it's always possible to build a declaration map from a from a library that contains recursive or nominal types. Another solution would be excluding your convex directory from your tsconfig.json and letting the convex/tsconfig.json file can cover the TypeScript files in your convex directory instead.

Did you find this page helpful?