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

It follows that, Ryan Cavanaugh should go with option 2 (prototypes) and Symbols!! #1

Open
arturohernandez10 opened this issue Apr 20, 2022 · 2 comments

Comments

@arturohernandez10
Copy link

Would you take a PR with some change to the readme, suggesting to go with 2. And adding support for it in Typescript such that.

myDate.addDays(3)

Is replaced by:

myDate[addDays](3)

Of course there is some type and code generation issues to resolve. But It seems like the sensitive thing to do.

@staeke
Copy link
Owner

staeke commented Apr 20, 2022

I agree. There is also a slightly simpler way in letting the function themselves index into the prototype, like

function addDays() { ... }
Date.prototype[addDays] = addDays

...but TS currently complains about that since addDays is not a symbol or string or number

@staeke
Copy link
Owner

staeke commented Apr 20, 2022

and to answer your question @arturohernandez10 - sure go ahead with a PR!

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

No branches or pull requests

2 participants