After creating a typescript class controller, I purposely omitted the "email" property in the payload. Surprisingly, no typescript error was thrown stating something like "email(undefined) is not equals to email(string)".
The issue arises when it smoothly executes the "console.log" without any interruption by an error. I anticipated that it would halt the execution since it does not conform to the type "testType" (please correct me if I am mistaken).
I am curious to hear your insights on how to address this situation effectively.
type testType = {
body: {
email: string
password: string
}
}
class Testing {
public static sampleFunc = async (req: testType, res: Response, next: NextFunction) => {
const temp = req.body
console.log('temp', temp);
// ..more code here
res.send('success');
}
}