Skip to content

fix: resolve TypeScript build errors#793

Open
hevink wants to merge 2 commits into
OpenCut-app:mainfrom
hevink:fix/build-type-errors
Open

fix: resolve TypeScript build errors#793
hevink wants to merge 2 commits into
OpenCut-app:mainfrom
hevink:fix/build-type-errors

Conversation

@hevink
Copy link
Copy Markdown

@hevink hevink commented May 16, 2026

Summary

Fixes all 5 TypeScript errors reported in #782 that cause bun run build and Docker builds to fail on main.

Closes #782

Changes

1. src/actions/keybinding.ts

Added missing isShortcutKey type guard function that persistence.ts imports but didn't exist.

2. src/actions/types.ts

Added missing isAction and isActionWithOptionalArgs type guard functions that persistence.ts imports but didn't exist. ACTIONS_WITH_REQUIRED_ARGS is declared at module scope to avoid recreating the Set on every call.

3. src/services/storage/migrations/runner.ts & v1-to-v2.ts

Fixed IndexedDBAdapter constructor calls — the constructor takes a single object { dbName, storeName, version } but was being called with 3 positional arguments (3 occurrences).

Also fixed projectsAdapter.set(projectId, result.project)projectsAdapter.set({ key: projectId, value: result.project }) to match the adapter's actual API.

4. src/stickers/providers/index.ts

Fixed stickersRegistry.register(id, provider)stickersRegistry.register({ key: id, definition: provider }) to match DefinitionRegistry.register's object param signature.

Testing

  • bun run build now completes successfully ✅
  • TypeScript check passes ✅
  • Docker build should now succeed ✅

- Add missing isShortcutKey type guard to keybinding.ts
- Add missing isActionWithOptionalArgs and isAction type guards to types.ts
- Fix IndexedDBAdapter constructor calls to use object params instead of positional args (runner.ts, v1-to-v2.ts)
- Fix StickersRegistry.register call to use object param { key, definition }
@vercel
Copy link
Copy Markdown

vercel Bot commented May 16, 2026

@hevink is attempting to deploy a commit to the OpenCut OSS Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 16, 2026

📝 Walkthrough

Walkthrough

Adds runtime type guards: isShortcutKey, isAction, and isActionWithOptionalArgs. Refactors IndexedDB adapter constructors and adapter set calls to use options-object parameters, and updates sticker provider registration to pass { key, definition }.

Changes

Action Validation & Keybinding Type Guards

Layer / File(s) Summary
Keybinding shortcut key validation
apps/web/src/actions/keybinding.ts
Introduces MODIFIER_KEYS_SET and exports isShortcutKey type guard to validate strings as single keys or modifier+key combinations (e.g., ctrl+s).
Action type guards and filtering
apps/web/src/actions/types.ts
Imports ACTIONS, caches its keys, and exports isAction and isActionWithOptionalArgs type guards to narrow and filter valid actions at runtime.

API Refactoring to Object-Based Parameters

Layer / File(s) Summary
Storage adapter constructor and method refactoring
apps/web/src/services/storage/migrations/runner.ts, apps/web/src/services/storage/migrations/v1-to-v2.ts
Refactors IndexedDBAdapter instantiations to use options-object form ({ dbName, storeName, version }) and updates projectsAdapter.set calls to pass object payloads ({ key, value }) instead of positional parameters.
Sticker provider registration refactoring
apps/web/src/stickers/providers/index.ts
Updates stickersRegistry.register calls to pass object payloads with { key, definition } fields instead of positional arguments.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • OpenCut-app/OpenCut#284: Related to the keybinding validation plumbing used for editor-wide keyboard shortcuts.
  • OpenCut-app/OpenCut#342: Also modifies keyboard shortcut handling/formatting; relates to validation and display normalization.
  • OpenCut-app/OpenCut#433: Touches keybinding system and parsing/recording logic relevant to this validator.

Suggested reviewers

  • mazeincoding

Poem

🐰 In code I nibble, tidy, and sew,

  • joins key and modifier — watch it go.
    Guards that check each action's name,
    Migrations updated, parameters tame.
    Hops away, commit done — bravo! ✨
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'fix: resolve TypeScript build errors' accurately summarizes the main objective of the changeset—fixing TypeScript type errors that prevent successful builds.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description check ✅ Passed The PR description is comprehensive and well-structured, covering all changes with clear explanations and testing confirmation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/web/src/actions/types.ts (1)

34-42: ⚡ Quick win

Move the constant Set to module level for better performance.

The ACTIONS_WITH_REQUIRED_ARGS Set is recreated on every function call. Following the same pattern as MODIFIER_KEYS_SET in keybinding.ts and ACTION_KEYS_SET in this file, declare it as a module-level constant.

♻️ Proposed refactor
 const ACTION_KEYS_SET: ReadonlySet<string> = new Set(Object.keys(ACTIONS));

+const ACTIONS_WITH_REQUIRED_ARGS: ReadonlySet<string> = new Set([
+	"remove-media-asset",
+	"remove-media-assets",
+]);
+
 export function isAction(value: string): value is TAction {
 	return ACTION_KEYS_SET.has(value);
 }

 export function isActionWithOptionalArgs(value: string): value is TActionWithOptionalArgs {
 	if (!isAction(value)) return false;
 	// Actions that require mandatory (non-undefined) args cannot be used as keybindings
-	const ACTIONS_WITH_REQUIRED_ARGS: ReadonlySet<string> = new Set([
-		"remove-media-asset",
-		"remove-media-assets",
-	]);
 	return !ACTIONS_WITH_REQUIRED_ARGS.has(value);
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/web/src/actions/types.ts` around lines 34 - 42, The
ACTIONS_WITH_REQUIRED_ARGS Set is recreated on every call inside
isActionWithOptionalArgs; pull that Set out to module scope as a top-level
constant (e.g., export or const ACTIONS_WITH_REQUIRED_ARGS = new Set([...])) so
it is instantiated once, mirroring the pattern used for MODIFIER_KEYS_SET and
ACTION_KEYS_SET (see keybinding.ts and this file), then update
isActionWithOptionalArgs to reference the module-level
ACTIONS_WITH_REQUIRED_ARGS.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@apps/web/src/actions/types.ts`:
- Around line 34-42: The ACTIONS_WITH_REQUIRED_ARGS Set is recreated on every
call inside isActionWithOptionalArgs; pull that Set out to module scope as a
top-level constant (e.g., export or const ACTIONS_WITH_REQUIRED_ARGS = new
Set([...])) so it is instantiated once, mirroring the pattern used for
MODIFIER_KEYS_SET and ACTION_KEYS_SET (see keybinding.ts and this file), then
update isActionWithOptionalArgs to reference the module-level
ACTIONS_WITH_REQUIRED_ARGS.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: dc1c898f-c2f9-45e0-9a67-1730bd79be04

📥 Commits

Reviewing files that changed from the base of the PR and between fbe3db7 and 25549b8.

📒 Files selected for processing (5)
  • apps/web/src/actions/keybinding.ts
  • apps/web/src/actions/types.ts
  • apps/web/src/services/storage/migrations/runner.ts
  • apps/web/src/services/storage/migrations/v1-to-v2.ts
  • apps/web/src/stickers/providers/index.ts

Per CodeRabbit review: avoid recreating the Set on every function call
by declaring it as a module-level constant, consistent with the pattern
used for MODIFIER_KEYS_SET and ACTION_KEYS_SET.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Docker build fails on main: 5 TypeScript errors prevent production build

1 participant