Skip to content

Conversation

dynst
Copy link
Contributor

@dynst dynst commented Aug 12, 2025

export interface JsonRpcSuccessResponse {
readonly jsonrpc: "2.0";
readonly id: JsonRpcId;
readonly result: any;
}

JsonCompatibleDictionary seems like it should be used in a lot of the many places that currently use any #1840, and also seems like it should be renamed JsonObject.

I'm guessing migrating to using real json validation like zod would be overkill.

https://www.npmjs.com/package/zod

But maybe it's not needed to reinvent JsonValue if we use this:

https://www.npmjs.com/package/type-fest

@dynst dynst changed the title remove readonly tags from json-rpc types export json types in utils Aug 12, 2025
@webmaster128
Copy link
Member

Interesting, looks good at first glance

I'm guessing migrating to using real json validation like zod would be overkill.

Yeah, agreed. Also I don't like external libraries in our public types which makes it very hard to replace dependencies.

@dynst
Copy link
Contributor Author

dynst commented Aug 13, 2025

external libraries in our public types which makes it very hard to replace dependencies.

And even just upgrading them, zod had a whole thing about how carefully the upgrade had to be designed due to how entangled it is with APIs.

colinhacks/zod#4371
https://zod.dev/v4

@dynst
Copy link
Contributor Author

dynst commented Oct 14, 2025

type-fest actually has its own widely adopted definition of JsonValue, package has 219 million downloads a week. Thoughts on using that in a public API?

https://github.com/sindresorhus/type-fest/blob/v5.1.0/source/json-value.d.ts
https://github.com/sindresorhus/type-fest/blob/v5.1.0/source/readonly-deep.d.ts

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