Eklayzia
Eklayzia
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
I do wish it were possible to use paths though 🤔 Nevermind, got it to work. Just have to configure the same path key to the relative values to each tsconfig, in both files.
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
Oh, actually, the paths thing was breaking it. Huh, it seems like the tsconfig from the overall project cannot reconcile with the paths configured in the convex tsconfig. I switched the imports in the convex schema back from relative to @, and it broke 🥲. Thanks Lee!
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
Thanks for everyone's help; hopefully, it doesn't break again.
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
Well, I'm not sure what I did to be honest besides deleting that file and adding it back in...
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
I added it for easier imports. I put the config file back (including the paths I added), and the typings are working now. I'm quite confused. This isn't the first time I've restarted my IDE, either.
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
I'm noticing that in my previous project that I made a few months ago, there is no tsconfig file in the convex/ directory. The current one has one, though it's generated.
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"isolatedModules": true,
"noEmit": true,
"paths": {
"@/*": ["./*"]
}
},
"include": ["./**/*"],
"exclude": ["./_generated"]
}
{
/* This TypeScript project config describes the environment that
* Convex functions run in and is used to typecheck them.
* You can modify it, but some settings required to use Convex.
*/
"compilerOptions": {
/* These settings are not required by Convex and can be modified. */
"allowJs": true,
"strict": true,
"moduleResolution": "Bundler",
"jsx": "react-jsx",
"skipLibCheck": true,
"allowSyntheticDefaultImports": true,

/* These compiler options are required by Convex */
"target": "ESNext",
"lib": ["ES2021", "dom"],
"forceConsistentCasingInFileNames": true,
"module": "ESNext",
"isolatedModules": true,
"noEmit": true,
"paths": {
"@/*": ["./*"]
}
},
"include": ["./**/*"],
"exclude": ["./_generated"]
}
I deleted it, and the type safety is working now. This doesn't seem right: "You can modify it, but some settings required to use Convex."
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
No description
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
Taking a look… I removed that bit; I'm not sure why I had that only for the object queries/mutation functions but not the others... my brain is fried. However, there are no improvements, and the other queries are still all any. schema/entities
export const getEntity = query({
args: {
entityId: v.id("entities"),
},
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error("Unauthenticated");
}

return await ctx.db.get(args.entityId);
},
});
export const getEntity = query({
args: {
entityId: v.id("entities"),
},
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
if (!identity) {
throw new Error("Unauthenticated");
}

return await ctx.db.get(args.entityId);
},
});
Has type:
const getEntity: RegisteredQuery<"public", {
entityId: Id<"entities">;
}, Promise<{
_id: Id<"entities">;
_creationTime: number;
name: string;
user: string;
objectId: Id<"objects">;
} | null>>
const getEntity: RegisteredQuery<"public", {
entityId: Id<"entities">;
}, Promise<{
_id: Id<"entities">;
_creationTime: number;
name: string;
user: string;
objectId: Id<"objects">;
} | null>>
But in a component:
import { useQuery } from "convex/react";
import { api } from "../../../../convex/_generated/api";
// ...
const entity = useQuery(api.schema.entities.getEntity, { entityId });
import { useQuery } from "convex/react";
import { api } from "../../../../convex/_generated/api";
// ...
const entity = useQuery(api.schema.entities.getEntity, { entityId });
Has type any for entity.
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
Though this should actually be Doc… | undefined right?
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
It would, though my understanding was that this should be automatic 🤔
16 replies
CCConvex Community
Created by Eklayzia on 1/10/2025 in #support-community
No query type safety
No description
16 replies