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" }],
},
};
};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; }'.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
typetype:const MyErrorResponse = scope({
Error: type({
message: "string",
code: "string",
}),
Response: {
code: "number==500",
contents: {
errors: "Error[]",
},
},
}).export().Response;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
typetype would be implied within scopescope