cosmjs icon indicating copy to clipboard operation
cosmjs copied to clipboard

export json types in utils

Open dynst opened this issue 4 months ago • 3 comments

https://github.com/cosmos/cosmjs/blob/ca243f58727d5d7ee0f46fc562fb816baf4fca62/packages/json-rpc/src/types.ts#L12-L16

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 avatar Aug 12 '25 20:08 dynst

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.

webmaster128 avatar Aug 13 '25 09:08 webmaster128

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.

https://github.com/colinhacks/zod/issues/4371 https://zod.dev/v4

dynst avatar Aug 13 '25 17:08 dynst

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

dynst avatar Oct 14 '25 20:10 dynst