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

Remove extends = Object from js_sys::{Number,JsString}? #1445

Closed
alexcrichton opened this issue Apr 11, 2019 · 5 comments
Closed

Remove extends = Object from js_sys::{Number,JsString}? #1445

alexcrichton opened this issue Apr 11, 2019 · 5 comments
Labels
js-sys Issues related to the `js-sys` crate question

Comments

@alexcrichton
Copy link
Contributor

In #1405 we seem to be leaning towards JsString both representing the native String class as well as the string primitive in JS. I suspect we'd want to do the same for Number too!

Currently, though, both these types inhereit from Object which means they Deref to Object. If we use native strings in JsString (which we actually already do) then this may not be quite right.

Should we remove the extends annotation from these types so they both deref to JsValue?

@alexcrichton alexcrichton added js-sys Issues related to the `js-sys` crate question labels Apr 11, 2019
@alexcrichton
Copy link
Contributor Author

cc @Pauan, you've likely got thoughts on this!

@RReverser
Copy link
Member

RReverser commented Apr 11, 2019

This is still fine, as they do inherit all the methods from Object.

For example, some_number.to_string() should indeed continue to work.

@Pauan
Copy link
Contributor

Pauan commented Apr 11, 2019

My thoughts on this are rather nuanced, so I'll need a bit of time to formulate a response, but @RReverser is correct that the Object methods should continue to work fine.

@alexcrichton
Copy link
Contributor Author

Ah ok intersting! I was unware of that :)

I'm gonna go ahead and close this, but @Pauan if you feel there's action that we need to take here a new issue/PR would be good!

@Pauan
Copy link
Contributor

Pauan commented Apr 12, 2019

Well, I had a detailed reply all written up, but after thinking about it, I like the current plan better: shift Number/Boolean/JsString to use primitives, but continue to have them extend from Object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
js-sys Issues related to the `js-sys` crate question
Projects
None yet
Development

No branches or pull requests

3 participants