From c953ce87536750499be0a555a1fdbaec6e86c363 Mon Sep 17 00:00:00 2001 From: exidz <81704272+exidz@users.noreply.github.com> Date: Mon, 1 Jul 2024 23:11:58 +0800 Subject: [PATCH] Add typings for preact-robot (#217) * chore: update package json to point typings properly * chore: add typings * chore: update package json to point typings properly --- packages/core/package.json | 4 +++- packages/preact-robot/index.d.ts | 12 ++++++++++++ packages/preact-robot/package.json | 4 +++- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 packages/preact-robot/index.d.ts diff --git a/packages/core/package.json b/packages/core/package.json index 1f0a1baf..783f3099 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,11 +3,13 @@ "version": "0.4.1", "description": "A functional, immutable Finite State Machine library", "main": "dist/machine.js", + "types": "./index.d.ts", "exports": { ".": { "require": "./dist/machine.js", "import": "./machine.js", - "default": "./machine.js" + "default": "./machine.js", + "types": "./index.d.ts" } }, "files": [ diff --git a/packages/preact-robot/index.d.ts b/packages/preact-robot/index.d.ts new file mode 100644 index 00000000..db72bff7 --- /dev/null +++ b/packages/preact-robot/index.d.ts @@ -0,0 +1,12 @@ +declare module "preact-robot" { + import type { Machine, SendFunction, Service } from "robot3"; + export function useMachine( + machine: M, + initialContext?: M["context"] + ): [ + M["state"] & { context: M["context"] }, + SendFunction, + Service + ]; + } + \ No newline at end of file diff --git a/packages/preact-robot/package.json b/packages/preact-robot/package.json index dc56c595..a3d02f33 100644 --- a/packages/preact-robot/package.json +++ b/packages/preact-robot/package.json @@ -4,10 +4,12 @@ "description": "Preact hooks for Robot finite state machines", "main": "dist/machine.js", "module": "machine.js", + "types": "./index.d.ts", "exports": { ".": { "require": "./dist/machine.js", - "default": "./machine.js" + "default": "./machine.js", + "types": "./index.d.ts" } }, "scripts": {