Skip to content

refactor: improve Signal typing with interface augmentation for framework-specific use() return types#143

Merged
Nowely merged 3 commits intonextfrom
improve-use-typing
Mar 7, 2026
Merged

refactor: improve Signal typing with interface augmentation for framework-specific use() return types#143
Nowely merged 3 commits intonextfrom
improve-use-typing

Conversation

@Nowely
Copy link
Owner

@Nowely Nowely commented Mar 7, 2026

Summary

Replaces the VueStore mapped type approach with TypeScript module augmentation on the Signal<T> interface, allowing each framework adapter to override the return type of use() without polluting the core types.

  • Core (defineState.ts): Converts Signal<T> from a type alias to an interface (enabling augmentation), and changes use() from a property to a method signature. UseHookFactory return type is relaxed to unknown.
  • Core (Store.ts): Uses the new StateObject<MarkputState> alias (cleaner than ReturnType<typeof defineState<...>>).
  • Vue adapter (useStore.ts): Adds a declare module '@markput/core' block that augments Signal<T> so use() returns Ref<T> — Vue components now get proper Ref<T> types without casting.

Motivation

The previous approach required maintaining a parallel VueStore mapped type that mirrored Store.state with Ref-wrapped values. This PR eliminates that duplication by letting TypeScript's module augmentation handle the per-framework narrowing at the source.

@vercel
Copy link

vercel bot commented Mar 7, 2026

Deployment failed with the following error:

Resource is limited - try again in 8 hours (more than 100, code: "api-deployments-free-per-day").

Learn More: https://vercel.com/nowelys-projects?upgradeToPro=build-rate-limit

@Nowely Nowely changed the title refactor: replace VueStore mapped type with Signal interface augmentation refactor: improve Signal typing with interface augmentation for framework-specific use() return types Mar 7, 2026
Nowely added 2 commits March 7, 2026 12:28
- Refactor typecheck scripts across multiple packages to standardize usage.
- Update package links in pnpm-lock.yaml to point to the 'dist' directory for better module resolution.
- Add TypeScript and Vue typecheck scripts to respective package.json files for improved type safety.
…ory references

- Adjusted package links for '@markput/react' and '@markput/vue' to point directly to the parent directory instead of the 'dist' subdirectory.
- Removed unnecessary package entries for 'packages/react/markput/dist' and 'packages/vue/markput/dist' to streamline the lock file.
@Nowely Nowely merged commit e6d4efc into next Mar 7, 2026
6 of 9 checks passed
@Nowely Nowely deleted the improve-use-typing branch March 7, 2026 09:33
Nowely pushed a commit that referenced this pull request Mar 7, 2026
🤖 I have created a release *beep* *boop*
---


## [0.5.0](0.4.0...0.5.0)
(2026-03-07)


### Features

* **core:** add ContentEditableController for DOM-based editing
([#134](#134))
([633133b](633133b))


### Refactoring

* extract shared logic from framework adapters to core
([#145](#145))
([795c0e8](795c0e8))
* improve Signal typing with interface augmentation for
framework-specific use() return types
([#143](#143))
([e6d4efc](e6d4efc))


### Miscellaneous

* migrate to pnpm catalog for centralized dependency management
([#140](#140))
([b71cd55](b71cd55))
* update oxlint configuration
([#144](#144))
([1db73ec](1db73ec))


### Tests

* add comprehensive Vue component tests with Vitest
([#142](#142))
([231f3dc](231f3dc))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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