Skip to content

type narrowing for getday #56865

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

Closed
imwh0im opened this issue Dec 24, 2023 · 1 comment
Closed

type narrowing for getday #56865

imwh0im opened this issue Dec 24, 2023 · 1 comment

Comments

@imwh0im
Copy link

imwh0im commented Dec 24, 2023

πŸ”Ž Search Terms

getday

πŸ•— Version & Regression Information

All versions

⏯ Playground Link

No response

πŸ’» Code

No response

πŸ™ Actual behavior

const now = new Date();
const now_day = now.getDay(); // type "number"

πŸ™‚ Expected behavior

const now = new Date();
const now_day = now.getDay(); // type "0 | 1 | 2 | 3 | 4 | 5 | 6"

Additional information about the issue

Using type narrowing will be return correct type and improve usability.

@MartinJohns
Copy link
Contributor

A change like this was previously rejected: #36401 (comment)

@imwh0im imwh0im closed this as completed Dec 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants