Skip to content

fix(types): export StringifyFunction interface - #89

Merged
BridgeAR merged 1 commit into
BridgeAR:mainfrom
anubhavlal07:fix/export-stringify-function
Nov 30, 2026
Merged

BridgeAR merged 1 commit into
BridgeAR:mainfrom
anubhavlal07:fix/export-stringify-function

Conversation

@anubhavlal07

Copy link
Copy Markdown
Contributor

index.d.ts declared interface StringifyFunction at module top level, outside declare namespace stringify. Because the file uses export = stringify, only members of the merged const/namespace are exported, so the type returned by configure() could not be named by consumers. With declaration: true, export const s = configure({ ... }) fails with TS4023, and import type { StringifyFunction } is not possible.

Fix

Move the interface into the namespace as export interface StringifyFunction, and reference it as stringify.StringifyFunction in both places in the stringify const declaration (its own type and the return type of configure). Runtime code is unchanged.

Test

Extended test-fixtures/types.mts and test-fixtures/types.cts to import StringifyFunction and assign configure(options) to it (plus stringify.StringifyFunction in the CJS fixture). The existing "TypeScript resolves both module formats" test compiles these fixtures. Without the fix it fails with TS2305: Module '"safe-stable-stringify"' has no exported member 'StringifyFunction'; with it, npm test passes.

Fixes #88

@BridgeAR BridgeAR left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

LGTM, thank you

@BridgeAR
BridgeAR merged commit eb583b3 into BridgeAR:main Nov 30, 2026
5 checks passed
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.

[Bug] Typescript can't compile when using configure on missing export "StringifyFunction"

2 participants