···130130 * Infers the TypeScript type for a lexicon namespace, returning only the 'main' definition
131131 * with all local refs (#user, #post, etc.) resolved to their actual types.
132132 */
133133-export type Infer<T extends { id: string; defs: Record<string, unknown> }> =
134134- Prettify<
135135- "main" extends keyof T["defs"]
136136- ? { $type: T["id"] } & ReplaceRefsInType<
137137- InferType<T["defs"]["main"]>,
138138- { [K in keyof T["defs"]]: InferType<T["defs"][K]> }
139139- >
140140- : never
141141- >;
133133+export type Infer<
134134+ T extends { json: { id: string; defs: Record<string, unknown> } },
135135+> = Prettify<
136136+ "main" extends keyof T["json"]["defs"]
137137+ ? { $type: T["json"]["id"] } & ReplaceRefsInType<
138138+ InferType<T["json"]["defs"]["main"]>,
139139+ { [K in keyof T["json"]["defs"]]: InferType<T["json"]["defs"][K]> }
140140+ >
141141+ : never
142142+>;
+1-1
packages/prototypey/src/lib.ts
···329329330330class Namespace<T extends LexiconNamespace> {
331331 public json: T;
332332- public infer: Infer<T> = null as unknown as Infer<T>;
332332+ public infer: Infer<{ json: T }> = null as unknown as Infer<{ json: T }>;
333333334334 constructor(json: T) {
335335 this.json = json;