Skip to content
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

[misc] Specify length of toArray return type #5766

Merged
merged 3 commits into from Oct 29, 2020

Conversation

mongoose700
Copy link
Contributor

toArray will always return an array with seven numbers. This change is necessary to be able to do new Date(...m.toArray()). As just number[], it complains with Expected 0-7 arguments, but got 0 or more..

toArray will always return an array with seven numbers. This change is necessary to be able to do `new Date(...m.toArray())`. As just `number[]`, it complains with `Expected 0-7 arguments, but got 0 or more.`.
@mongoose700 mongoose700 changed the title Specify length of toArray return value [misc] Specify length of toArray return value Oct 28, 2020
@coveralls
Copy link

coveralls commented Oct 28, 2020

Coverage Status

Coverage increased (+0.03%) to 88.525% when pulling 31bee3f on mongoose700:patch-1 into 0dcaaa6 on moment:develop.

@marwahaha
Copy link
Member

Interesting.

Is this TS 1.x compatible?

Otherwise, you can update the ts3.1 typings.

@mongoose700
Copy link
Contributor Author

Tuples were added in 1.3, so not quite.

@marwahaha
Copy link
Member

@mongoose700 Thanks for the update. Could you also add a test https://github.com/moment/moment/blob/develop/ts3.1-typing-tests/moment-tests.ts and I'll merge it

@mongoose700
Copy link
Contributor Author

I wanted to add a test that invoked new Date(...moment().toArray()), but the spread syntax wasn't available, and apply isn't type-safe.

@marwahaha
Copy link
Member

Thanks!

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 this pull request may close these issues.

None yet

4 participants