From 5208661702f0f4ac65f7978f4bd8b35a657944a9 Mon Sep 17 00:00:00 2001 From: Mike Cann Date: Wed, 28 Jan 2026 07:53:44 +0800 Subject: [PATCH 1/3] making convex typecheck by setting the correct lib version --- convex/tsconfig.json | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/convex/tsconfig.json b/convex/tsconfig.json index 6907537..41bfbb9 100644 --- a/convex/tsconfig.json +++ b/convex/tsconfig.json @@ -1,7 +1,25 @@ { - "extends": "../tsconfig.json", + /* 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 are required to use Convex. + */ "compilerOptions": { + /* These settings are not required by Convex and can be modified. */ + "allowJs": true, + "strict": true, "moduleResolution": "Bundler", - "skipLibCheck": true - } + "jsx": "react-jsx", + "skipLibCheck": true, + "allowSyntheticDefaultImports": true, + + /* These compiler options are required by Convex */ + "target": "ESNext", + "lib": ["ES2023", "dom"], + "forceConsistentCasingInFileNames": true, + "module": "ESNext", + "isolatedModules": true, + "noEmit": true + }, + "include": ["./**/*"], + "exclude": ["./_generated"] } From 7d97cc62eec049722e9a947a5795e3de0c428d48 Mon Sep 17 00:00:00 2001 From: Mike Cann Date: Wed, 28 Jan 2026 09:16:27 +0800 Subject: [PATCH 2/3] going back to what convex dev will auto-set --- convex/README.md | 90 ++++++++++++++++++++++++++++++++++++++++++++ convex/tsconfig.json | 2 +- 2 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 convex/README.md diff --git a/convex/README.md b/convex/README.md new file mode 100644 index 0000000..91a9db2 --- /dev/null +++ b/convex/README.md @@ -0,0 +1,90 @@ +# Welcome to your Convex functions directory! + +Write your Convex functions here. +See https://docs.convex.dev/functions for more. + +A query function that takes two arguments looks like: + +```ts +// convex/myFunctions.ts +import { query } from "./_generated/server"; +import { v } from "convex/values"; + +export const myQueryFunction = query({ + // Validators for arguments. + args: { + first: v.number(), + second: v.string(), + }, + + // Function implementation. + handler: async (ctx, args) => { + // Read the database as many times as you need here. + // See https://docs.convex.dev/database/reading-data. + const documents = await ctx.db.query("tablename").collect(); + + // Arguments passed from the client are properties of the args object. + console.log(args.first, args.second); + + // Write arbitrary JavaScript here: filter, aggregate, build derived data, + // remove non-public properties, or create new objects. + return documents; + }, +}); +``` + +Using this query function in a React component looks like: + +```ts +const data = useQuery(api.myFunctions.myQueryFunction, { + first: 10, + second: "hello", +}); +``` + +A mutation function looks like: + +```ts +// convex/myFunctions.ts +import { mutation } from "./_generated/server"; +import { v } from "convex/values"; + +export const myMutationFunction = mutation({ + // Validators for arguments. + args: { + first: v.string(), + second: v.string(), + }, + + // Function implementation. + handler: async (ctx, args) => { + // Insert or modify documents in the database here. + // Mutations can also read from the database like queries. + // See https://docs.convex.dev/database/writing-data. + const message = { body: args.first, author: args.second }; + const id = await ctx.db.insert("messages", message); + + // Optionally, return a value from your mutation. + return await ctx.db.get("messages", id); + }, +}); +``` + +Using this mutation function in a React component looks like: + +```ts +const mutation = useMutation(api.myFunctions.myMutationFunction); +function handleButtonPress() { + // fire and forget, the most common way to use mutations + mutation({ first: "Hello!", second: "me" }); + // OR + // use the result once the mutation has completed + mutation({ first: "Hello!", second: "me" }).then((result) => + console.log(result), + ); +} +``` + +Use the Convex CLI to push your functions to a deployment. See everything +the Convex CLI can do by running `npx convex -h` in your project root +directory. To learn more, launch the docs with `npx convex docs`. diff --git a/convex/tsconfig.json b/convex/tsconfig.json index 41bfbb9..7374127 100644 --- a/convex/tsconfig.json +++ b/convex/tsconfig.json @@ -14,7 +14,7 @@ /* These compiler options are required by Convex */ "target": "ESNext", - "lib": ["ES2023", "dom"], + "lib": ["ES2021", "dom"], "forceConsistentCasingInFileNames": true, "module": "ESNext", "isolatedModules": true, From a86208454204732bdd28957d8db276aaff7b2e74 Mon Sep 17 00:00:00 2001 From: Mike Cann Date: Wed, 28 Jan 2026 09:18:11 +0800 Subject: [PATCH 3/3] okay changing these lines to be es 2021 compliant --- convex/githubImport.ts | 3 ++- convex/lib/githubImport.ts | 6 ++++-- convex/lib/skills.ts | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/convex/githubImport.ts b/convex/githubImport.ts index 4a803b3..aee653c 100644 --- a/convex/githubImport.ts +++ b/convex/githubImport.ts @@ -85,7 +85,8 @@ export const previewGitHubImportCandidate = action({ defaultSelectedPaths, }) - const baseForNaming = candidate.path ? (candidate.path.split('/').at(-1) ?? '') : resolved.repo + const pathParts = candidate.path ? candidate.path.split('/') : [] + const baseForNaming = candidate.path ? (pathParts[pathParts.length - 1] ?? '') : resolved.repo const suggestedDisplayName = suggestDisplayName(candidate, baseForNaming) const rawSlugBase = sanitizeSlug(candidate.path ? baseForNaming : resolved.repo) diff --git a/convex/lib/githubImport.ts b/convex/lib/githubImport.ts index 85b12b6..74c9b98 100644 --- a/convex/lib/githubImport.ts +++ b/convex/lib/githubImport.ts @@ -141,7 +141,8 @@ async function resolveHeadCommit(parsed: GitHubImportUrl, fetcher: typeof fetch) url = next.toString() } - const maybe = url.split('/').at(-1) ?? '' + const urlParts = url.split('/') + const maybe = urlParts[urlParts.length - 1] ?? '' if (!/^[a-f0-9]{40}$/i.test(maybe)) { throw new Error('Could not resolve commit for HEAD') } @@ -363,7 +364,8 @@ function isUnderRoot(path: string, rootWithSlash: string) { function isTextPath(path: string) { const lower = path.toLowerCase() - const ext = lower.split('.').at(-1) ?? '' + const extParts = lower.split('.') + const ext = extParts[extParts.length - 1] ?? '' if (!ext) return false return TEXT_FILE_EXTENSION_SET.has(ext) } diff --git a/convex/lib/skills.ts b/convex/lib/skills.ts index 5d48e68..a1b3461 100644 --- a/convex/lib/skills.ts +++ b/convex/lib/skills.ts @@ -127,7 +127,7 @@ export function isTextFile(path: string, contentType?: string | null) { const trimmed = path.trim().toLowerCase() if (!trimmed) return false const parts = trimmed.split('.') - const extension = parts.length > 1 ? (parts.at(-1) ?? '') : '' + const extension = parts.length > 1 ? (parts[parts.length - 1] ?? '') : '' if (contentType) { if (isTextContentType(contentType)) return true }