Skip to content

test: cover public type surface#12

Merged
anton62k merged 1 commit into
masterfrom
test/type-surface
May 23, 2026
Merged

test: cover public type surface#12
anton62k merged 1 commit into
masterfrom
test/type-surface

Conversation

@anton62k

@anton62k anton62k commented May 23, 2026

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Type safety enhancements:
    • Added NoExtraKeys utility to createForm to enforce valid field and array path configuration.
  • New type testing:
    • Added test/types/form-types.test-d.ts to verify form controls, patch types, and error handling.
  • Documentation updates:
    • Updated README.md, architecture.md, and limitations.md with details on the TypeScript contract and type testing strategy.
  • Internal refactor:
    • Simplified MobxForm array configuration assignment by removing unnecessary type casting.

This will update automatically on new commits.

Summary by CodeRabbit

  • Documentation

    • Added a TypeScript Contract section with examples showing typed form values, controls, arrays, reset, and server-error handling
    • Expanded architecture and limitations docs with guidance on generic typing and where explicit helper generics are needed
  • Type System Improvements

    • Tighter compile-time checks to reject invalid field/array paths and enforce consistent typed operations
  • Tests

    • Added compile-time type tests verifying correct and incorrect typed usages

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 23, 2026

Copy link
Copy Markdown

Caution

Review failed

Pull request was closed or merged during review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 048c6489-f5a6-443d-bfa9-6f171ad00aa6

📥 Commits

Reviewing files that changed from the base of the PR and between faf01a2 and 34bf591.

📒 Files selected for processing (5)
  • README.md
  • docs/architecture.md
  • docs/limitations.md
  • src/form.ts
  • test/types/form-types.test-d.ts
✅ Files skipped from review due to trivial changes (3)
  • docs/limitations.md
  • docs/architecture.md
  • README.md

📝 Walkthrough

Walkthrough

This PR adds a NoExtraKeys utility and applies it to CreateFormOptions to restrict configured fields and arrays to valid FieldPath/ArrayPath keys derived from defaultValues, removes an unnecessary unknown cast when storing array configs in MobxForm, adds a comprehensive TypeScript .d.ts test exercising positive and negative type checks for form APIs, and updates README/architecture/limitations docs to describe the typing contract and where explicit helper generics are required.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: cover public type surface' accurately describes the main objective of adding comprehensive type-level tests and documenting the TypeScript contract to ensure the public type surface is properly validated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/type-surface

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

@gitar-bot gitar-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Gitar has auto-approved this PR (configure)

@anton62k anton62k force-pushed the test/type-surface branch from faf01a2 to 34bf591 Compare May 23, 2026 02:33
@gitar-bot

gitar-bot Bot commented May 23, 2026

Copy link
Copy Markdown
Code Review ✅ Approved

Adds type safety via the NoExtraKeys utility and implements comprehensive type testing for form controls, patching, and error handling. No issues were found.

Auto-approved: No blocking issues found.
Please see Auto-approve Docs for details on setting custom approval criteria.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/form.ts (1)

571-571: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove the unnecessary cast at Line 571 to resolve Sonar S4325.

This assertion is redundant and currently fails CI quality checks.

Suggested fix
-      this.#arrayConfigs.set(name, config as ArrayFieldConfig<unknown>);
+      this.#arrayConfigs.set(name, config);
🤖 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 `@src/form.ts` at line 571, Remove the redundant type assertion when storing
array field configs: update the call to this.#arrayConfigs.set(name, config) so
it no longer casts config to ArrayFieldConfig<unknown>; ensure the variable
names referenced (this.#arrayConfigs, name, config) remain unchanged and let
TypeScript infer the type to satisfy Sonar S4325.
🤖 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.

Outside diff comments:
In `@src/form.ts`:
- Line 571: Remove the redundant type assertion when storing array field
configs: update the call to this.#arrayConfigs.set(name, config) so it no longer
casts config to ArrayFieldConfig<unknown>; ensure the variable names referenced
(this.#arrayConfigs, name, config) remain unchanged and let TypeScript infer the
type to satisfy Sonar S4325.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 13ce0b80-9cc0-4e26-8399-72e8dcda18b7

📥 Commits

Reviewing files that changed from the base of the PR and between d6fd6a4 and faf01a2.

📒 Files selected for processing (5)
  • README.md
  • docs/architecture.md
  • docs/limitations.md
  • src/form.ts
  • test/types/form-types.test-d.ts

@anton62k anton62k merged commit 4947823 into master May 23, 2026
3 of 4 checks passed
@anton62k anton62k deleted the test/type-surface branch May 23, 2026 02:36
anton62k added a commit that referenced this pull request May 23, 2026
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.

1 participant