diff --git a/src/deserializer.ts b/src/deserializer.ts index c6b1faf..3f5f249 100644 --- a/src/deserializer.ts +++ b/src/deserializer.ts @@ -121,7 +121,7 @@ type AppendLinks< TDeserializer extends AnyResourceDeserializer, TBase, TLinksSchema extends LinksSchema | undefined = InferPropertyType, -> = TLinksSchema extends LinksSchema ? TBase & { $links: z.output } : TBase; +> = TLinksSchema extends LinksSchema ? TBase & { $links: z.output } : TBase; type AppendMeta< TDeserializer extends AnyResourceDeserializer, diff --git a/test/selector.test.ts b/test/selector.test.ts index 59292b3..3008e54 100644 --- a/test/selector.test.ts +++ b/test/selector.test.ts @@ -198,6 +198,32 @@ describe("createResourceSelector", () => { }, }); }); + + it("should parse resource links", () => { + const selector = createResourceSelector({ + type: "article", + linksSchema: z.object({ + self: z.string(), + }), + }); + + const result = selector({ + data: { + id: "ID-p", + type: "article", + links: { self: "foo" }, + }, + }); + + expect(result).toEqual({ + data: { + id: "ID-p", + $links: { + self: "foo", + }, + }, + }); + }); }); describe("createNullableResourceSelector", () => {