Property 'name' is missing in type

const MyErrorResponse = scope({
  Error: {
    message: "string",
    code: "string",
  },
  Response: {
    code: "number==500",
    contents: {
      errors: "Error[]",
    },
  },
}).export().Response;
type MyErrorResponse = typeof MyErrorResponse.infer;

const createErrorResponse = (): MyErrorResponse => {
  return {
    code: 500,
    contents: {
      errors: [{ message: "example", code: "ERROR" }],
    },
  };
};

This results in error:
Property 'name' is missing in type '{ message: string; code: string; }' but required in type '{ message: string; code: string; name: never; stack?: undefined; cause?: undefined; }'.

This can be resolved by using type:
const MyErrorResponse = scope({
  Error: type({
    message: "string",
    code: "string",
  }),
  Response: {
    code: "number==500",
    contents: {
      errors: "Error[]",
    },
  },
}).export().Response;

Is this the intended usage, or a bug? Because I was expecting that type would be implied within scope
Was this page helpful?