mm-ninja-turtles / turtle-express

My attempt of making Express.JS a typesafe router with Zod.
3 stars 0 forks source link

[feature]: Typescript cannot detect the undefined properties of (params,body,query of ctx) #44

Closed PyaePhyoKyaw61194 closed 2 years ago

PyaePhyoKyaw61194 commented 2 years ago
Screenshot 2022-08-20 at 00 46 23

Typescript cannot detect the name property that is not existed.

PyaePhyoKyaw61194 commented 2 years ago

I just added the query object in request without any property. In this case, typescript can detect the undefined error( name not existed in query) perfectly.

Screenshot 2022-08-20 at 00 54 43
wai-lin commented 2 years ago

This might be the case that I need to type the defaults of context elements to unknown so that typescript can show error correctly. I'll need to investigate more.

PyaePhyoKyaw61194 commented 2 years ago

Trying to copy the logic of ResolverArgs return type changing dynamically( ctx,req,res or ctx,req) with respect to UncontrolledResolver true or false. But , still failed.

wai-lin commented 2 years ago

Yep it would still be the same result since ResolverArgs need to type more strictly.

wai-lin commented 2 years ago

55

wai-lin commented 2 years ago

This should be solved. I'll close the issue.