So I have a check like this
var invalid = check(username, address);
if (invalid) {
errorText.innerHTML = invalid.message;
errorText.style.display = "block";
return;
}
and my function
function check(username: string, address: string): Error | boolean{
if (!username || typeof username !== "string" || username === "") {
const err = new Error("Please provide a username.");
return err;
}
return false
as you can see my check function returns an error or false if no error is present, in the first code block I check if error is present and then show message, but ts gives me this error "Property 'message' does not exist on type 'true | Error'.
Property 'message' does not exist on type 'true'