-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Types] Consider exposing PropertyNames types #10200
Comments
any updates on this? It would be really useful! |
Any updates with this? Would be really useful! 👍🏼 |
Any updates on this issue? |
PR welcome 🙂 |
Is anyone working on this? if not I'd love to give it a go 👍 |
Go for it! |
Interestingly since #12089 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
🚀 Feature Proposal
Please consider exposing
NonFunctionPropertyNames<T>
,FunctionPropertyNames<T>
andConstructorPropertyNames<T>
Motivation
Sometimes types are not infered as desired. Exposing these types could help developers to provide Typescript hints to infer types in some corner cases
Example
Consider your actual type
spyOn
:Consider a mock on
global.Date
:The actual code throws the following syntax error:
Why is this happening?
Well, if we look NodeJS.Global Types:
Then, if we look for
Date
As you can realize, Typescript tries to match spyOn in the order provided in the type file. As long as
DateConstructor
is a validFunctionPropertyNames<T>
, Typescript asumes I'm using the following call:But as long as Date includes
(): string
, Typescript infers its a SpyInstance<string, []>Solution
Exposing these types (
NonFunctionPropertyNames<T>
,FunctionPropertyNames<T>
andConstructorPropertyNames<T>
) would help us provide hints to Typescript:Do you think it could be possible? Thank you so much for your time and effort
The text was updated successfully, but these errors were encountered: