arktypea
arktype10mo ago
imMohika

undeclared keys in nested object

Hello.
I want to use arktype for parsing objects in backend before sending them to client (mainly for removing unwanted keys),
But when i use nested object types the undeclared keys won't get deleted

ex:
export const tUser = type({
  "+": "delete",
  phoneNumber: "string",
  type: tUserType,
});

export const tAuthMeResult = type({
  "requiresOnboarding?": "boolean",
  "user?": tUser,
  "account?": tAccount,
});


result in
{
  "user": {
    "id": 2,
    "phoneNumber": "XXXX",
    "type": "user",
    "createdAt": "2025-03-06T12:50:43.849Z",
    "updatedAt": "2025-03-06T12:50:43.849Z"
  },


wanted result:
"user": {
    "phoneNumber": "XXXX",
    "type": "user"
  },


Is this a limitation or am i doing something wrong?

Thanks for your time
Was this page helpful?