-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Change timeoutIdRef
type number to ReturnType<typeof setTimout>
#29834
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
base: develop
Are you sure you want to change the base?
Change timeoutIdRef
type number to ReturnType<typeof setTimout>
#29834
Conversation
We use number for timeout IDs throughout the element web codebase as it only runs in browsers. That said, I'm also getting the same error so something must have changed to make this type check fail sometimes. The correct solution is probably to find out what that is, and then if the answer is to change the types, we should do it everywhere. |
Hello. Thanks for your comment!
I looked at the tsconfig file and it seems like the settings are set to recognize based on the DOM, which is definitely interesting.... |
This comment was marked as off-topic.
This comment was marked as off-topic.
Looking at other codes that used setTimeout, it seems that there are places where window.setTimeout is used globally and places where it is not used. It seems that it was used selectively depending on the situation, so should I unify this? |
timeoutIdRef
type number to ReturnType<typeof setTimout>
Apologies, I went to ask the team about this and then forgot. I just brought it up again in our meeting and the solution suggested was to try overriding the return type of setTimeout (not I'm not sure if this is a piece of work you'd be willing to take on. |
Hello. Thank you for your reply. I read your reply. If this PR is not a serious issue that needs to be addressed immediately within the team, would you mind if I take it on? I have been using Element internally and would like to contribute this time if it is okay. Also, I think it would be a good learning experience to look at the code while contributing. |
That would be great if you're happy to pick it up - thank you! |
Bug Overview
During the code check using the yarn lint script, the following error was found.

Solution
After looking into the cause, I found out that the browser return type of the setTimeout function is a number type, but in NodeJS, it is returned as a Timeout type.
Because of this, it worked normally in the browser environment, but an error occurred during lint verification.
Therefore, I used ReturnType to handle it so that it could pass lint verification without being affected by the environment.
The solution was completed after that.

public
/exported
symbols have accurate TSDoc documentation.