vercel-labs / vercel-labs/json-render
feat: Generic `Spec` type support
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 16.8k
- Forks
- 901
- Avg merge
- 3h 14m
- Merged PRs (30d)
- 4
Description
Hi, it seems like we don't support exporting a generic Spec type, currently Spec looks like this:
interface Spec {
/** Root element key */
root: string;
/** Flat map of elements by key */
elements: Record<string, UIElement>;
/** Optional initial state to seed the state model.
* Components using statePath will read from / write to this state. */
state?: Record<string, unknown>;
}
However, UIElement is a fully generic type:
interface UIElement<T extends string = string, P = Record<string, unknown>> {
/** Component type from the catalog */
type: T;
/** Component props */
props: P;
// ...
I wonder if we could add support for a Spec<T, P> type as well. For context, I want to pass Spec as a type to a React Hook Form form, but the type of elements should be limited to my own catalog only, and I have no way to that now without redefining Spec myself.
Thank you.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the exported Spec and UIElement type definitions and checking how Spec is consumed by the React Hook Form integration. Define the generic relationship between the element catalog and props while preserving existing Spec usage; done means consumers can constrain elements to their own catalog without redefining Spec.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100