Export `stringify` separately
nicholaschiang opened this issue · 1 comments
nicholaschiang commented
It seems like the Typescript definition for superjson
only exports the stringify
method as a properly of the default export:
import { SuperJSONResult, SuperJSONValue, Class, JSONValue } from './types';
import { RegisterOptions } from './class-registry';
import { CustomTransfomer } from './custom-transformer-registry';
export declare const serialize: (object: SuperJSONValue) => SuperJSONResult;
export declare const deserialize: <T = unknown>(payload: SuperJSONResult) => T;
export declare const parse: <T = unknown>(string: string) => T;
declare const _default: {
stringify: (object: any) => string;
parse: <T = unknown>(string: string) => T;
serialize: (object: any) => SuperJSONResult;
deserialize: <T_1 = unknown>(payload: SuperJSONResult) => T_1;
registerClass: (v: Class, options?: string | RegisterOptions | undefined) => void;
registerSymbol: (v: Symbol, identifier?: string | undefined) => void;
registerCustom: <I, O extends JSONValue>(transformer: Omit<CustomTransfomer<I, O>, "name">, name: string) => void;
allowErrorProps: (...props: string[]) => void;
};
export default _default;
Because of this, I can't:
import { parse, stringify } from 'superjson';
Because parse
is exported but stringify
isn't. And I've got no idea why it isn't.
Skn0tt commented
oh, I think that's just an export
missing here:
https://github.com/blitz-js/superjson/blob/86705ea17eba1c6c1c6922396d0b083b8b80eca1/src/index.ts#L63
Wanna submit a PR for that? I'd happily review it.