oak
oak copied to clipboard
fix: getQuery() may have undefined values
Hello, I am using Deno to try to write a chatroom demo, and now I think I've encountered a problem. Here's an example code:
const username = helpers.getQuery(context).username;
Here the VSCode just infers that the type of username is just string and wouldn't be undefined because the type of the return value of getQuery() is Record<string, string>. But in fact it sometimes does occur. And it also made me ignore considering the situation that the username would be empty so I didn't write the relevant code to check and avoid it. It may make debug hard so I just modified the type of the return value.