types: make model types support sync AND async methods#347
types: make model types support sync AND async methods#347jankapunkt wants to merge 2 commits intomasterfrom
Conversation
|
Thanks for this |
|
So I have an opinion here, this isn't really about runtime compatibility (which is fine), since the lib treats every model function as async, but about whether the type system should match what the documentation states. I think really there are 2 possible solutions:
To me option 2 seems cleaner — the current typings enforce consistent async shape and avoid noisy unions. Since async functions support returning sync values anyway, for example, just wrap it in async? That will always return a promise. (async () => 'foo')(); // returns a resolved PromiseWhat do yall think? |
|
I agree with @HappyZombies - people can mark their function If the OP of the discussion doesn't like sticking to the type declaration, then use JS, if they want to use TS they they'll need to adhere to the typings because those are the intended (rather than possible) interfaces |
|
@HappyZombies @dhensby thank you for your input. Since I'm no TypeScript pro I can't really add valuable information. Feel free to close, if you think this is out of scope. |
Summary
This is proof of concept for further discussion, related to #344
Please add your opinion and review.
Linked issue(s)
#344
Involved parts of the project
Types
Added tests?
OAuth2 standard
Reproduction
Custom IDE related