Skip to content

feat: improve TS typing and refactor examples - #18

Merged
lucataglia merged 4 commits into
mainfrom
feat/improve-ts
Feb 20, 2026
Merged

lucataglia merged 4 commits into
mainfrom
feat/improve-ts

Conversation

@lucataglia

Copy link
Copy Markdown
Collaborator

No description provided.

@lucataglia
lucataglia requested a review from rivamarco February 19, 2026 09:31
@TheFe91

TheFe91 commented Feb 19, 2026 •

Copy link
Copy Markdown
  1. SuccessSubmitCallback vs SubmitSuccessCallback — inconsistent naming

// src/types/index.ts
export type SubmitSuccessCallback = ...
/** @deprecated Use {@link SubmitSuccessCallback} instead. */
export type SuccessSubmitCallback = SubmitSuccessCallback

The [Verb][Noun]Callback pattern (e.g. CheckSuccessCallback, CheckErrorCallback) is used for check callbacks, but submit uses SubmitSuccessCallback. This is fine, but worth noting as an
explicit naming decision.

  1. PrivateValidateForm moved without apparent breaking change, but with semantic shift

// Previously in the public section, now @internal
export type PrivateValidateForm = (...)

It was already @Private in JSDoc, but it's still exported. If someone imports it directly (unlikely but possible), there's no deprecation warning. Consider whether to add @deprecated or
leave it as is.

  1. liveValidation — ambiguous name in FormbitObject

liveValidation: (path: string) => true | undefined,

The liveValidation field in the return object was previously of type LiveValidationFn (a function), and LiveValidation in the state was the record. Now both are named liveValidation
(one is the function, the other is the field in the writer), but in FormState the field is typed as liveValidation: LiveValidation (the Record). This can create confusion: a consumer
reading formbit.liveValidation expects a function, but writer.liveValidation is a record. Not a bug, but an asymmetry worth documenting.

  1. FormbitObject — check at the bottom

return {
// ...
submitForm,
check // ← last
}

In the return object ordering, mutations follow a logical sequence (write → remove → initialize → reset → set → validate → submit → check), but check is semantically different from
submitForm — it doesn't mutate state, it doesn't submit, it's closer to a query. It could belong in the // Queries section.

  1. FormbitValues and Form / InitialValues are now aliases of the same type — this clarifies that Form and InitialValues are interchangeable, but it might be worth documenting
    explicitly.

@lucataglia

Copy link
Copy Markdown
Collaborator Author
  1. SuccessSubmitCallback vs SubmitSuccessCallback — inconsistent naming

// src/types/index.ts export type SubmitSuccessCallback = ... /** @deprecated Use {@link SubmitSuccessCallback} instead. */ export type SuccessSubmitCallback = SubmitSuccessCallback

The [Verb][Noun]Callback pattern (e.g. CheckSuccessCallback, CheckErrorCallback) is used for check callbacks, but submit uses SubmitSuccessCallback. This is fine, but worth noting as an explicit naming decision.

  1. PrivateValidateForm moved without apparent breaking change, but with semantic shift

// Previously in the public section, now @internal export type PrivateValidateForm = (...)

It was already @Private in JSDoc, but it's still exported. If someone imports it directly (unlikely but possible), there's no deprecation warning. Consider whether to add @deprecated or leave it as is.

  1. liveValidation — ambiguous name in FormbitObject

liveValidation: (path: string) => true | undefined,

The liveValidation field in the return object was previously of type LiveValidationFn (a function), and LiveValidation in the state was the record. Now both are named liveValidation (one is the function, the other is the field in the writer), but in FormState the field is typed as liveValidation: LiveValidation (the Record). This can create confusion: a consumer reading formbit.liveValidation expects a function, but writer.liveValidation is a record. Not a bug, but an asymmetry worth documenting.

  1. FormbitObject — check at the bottom

return { // ... submitForm, check // ← last }

In the return object ordering, mutations follow a logical sequence (write → remove → initialize → reset → set → validate → submit → check), but check is semantically different from submitForm — it doesn't mutate state, it doesn't submit, it's closer to a query. It could belong in the // Queries section.

  1. FormbitValues and Form / InitialValues are now aliases of the same type — this clarifies that Form and InitialValues are interchangeable, but it might be worth documenting
    explicitly.
  1. SubmitSuccessCallback naming — No change. Pattern is consistent with CheckSuccessCallback/CheckErrorCallback.
  2. PrivateValidateForm missing @deprecated — No change. Already @internal @Private, no consumer should use it.
  3. liveValidation name ambiguity — No change. Function vs record is inherent to the high-level API vs raw state design.
  4. check belongs in Queries, not Mutations — Done. Moved check to the Queries section.
  5. FormbitValues/Form/InitialValues aliases — No change. JSDoc already explains each.
  6. Deprecated types for backward compatibility — Kept. They give consumers a migration window before a future major bump.

@lucataglia lucataglia added the enhancement New feature or request label Feb 20, 2026
@lucataglia
lucataglia merged commit 32f4ba4 into main Feb 20, 2026
3 checks passed
@lucataglia
lucataglia deleted the feat/improve-ts branch February 20, 2026 09:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants