oak icon indicating copy to clipboard operation
oak copied to clipboard

fix: getQuery() may have undefined values

Open lomirus opened this issue 4 years ago • 1 comments

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.

lomirus avatar Oct 29 '21 17:10 lomirus

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Oct 29 '21 17:10 CLAassistant