Skip to content

feat: add 'function' support to fp-sdk's primitive type guards#24

Open
nodefect wants to merge 1 commit into
tarsgate:mainfrom
nodefect:feat/function-type-guard
Open

feat: add 'function' support to fp-sdk's primitive type guards#24
nodefect wants to merge 1 commit into
tarsgate:mainfrom
nodefect:feat/function-type-guard

Conversation

@nodefect

@nodefect nodefect commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Adds Function to the set of supported primitive types in Dyn.cast().to() and Dyn.tryCast().to().

Changes

  • Extended the conditional return types in src/dyn.ts to include FunctionConstructorFunction
  • Added test coverage for function casting in src/fpSdk.test.ts

Why

fp-sdk already supports dynamic casting for primitive types (String, Number, Boolean) and custom classes, but Function was missing from the type mapping and had no test coverage. This PR fills that gap so users can now do:

const fn = () => "hello";
Dyn.tryCast(fn).to(Function); // Option<Function>

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.

2 participants