-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Add Symbol.species to ArrayConstructor, MapConstructor, SetConstructo… #18652
Conversation
…r, ArrayBufferConstructor. Fix Symbol.species in RegExpConstructor and PromiseConstructor. See microsoft#2881 .
Symbol.species on TypedArrays still needs to be added, but it's implementation depends on whether i #18559 is accepted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable. @rbuckton should take a look here though.
@@ -150,7 +150,7 @@ interface Promise<T> { | |||
} | |||
|
|||
interface PromiseConstructor { | |||
readonly [Symbol.species]: Function; | |||
readonly [Symbol.species]: PromiseConstructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the spec, the property type should be this
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@DanielRosenwasser, do you know if using a this
type here would be problematic for someone writing a subclass?
@@ -202,7 +202,7 @@ interface RegExp { | |||
} | |||
|
|||
interface RegExpConstructor { | |||
[Symbol.species](): RegExpConstructor; | |||
readonly [Symbol.species]: RegExpConstructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the spec, the property type should be this
.
@@ -283,3 +283,16 @@ interface Float32Array { | |||
interface Float64Array { | |||
readonly [Symbol.toStringTag]: "Float64Array"; | |||
} | |||
|
|||
interface ArrayConstructor { | |||
readonly [Symbol.species]: ArrayConstructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the spec, the property type should be this
.
readonly [Symbol.species]: ArrayConstructor; | ||
} | ||
interface MapConstructor { | ||
readonly [Symbol.species]: MapConstructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the spec, the property type should be this
.
readonly [Symbol.species]: MapConstructor; | ||
} | ||
interface SetConstructor { | ||
readonly [Symbol.species]: SetConstructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the spec, the property type should be this
.
readonly [Symbol.species]: SetConstructor; | ||
} | ||
interface ArrayBufferConstructor { | ||
readonly [Symbol.species]: ArrayBufferConstructor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the spec, the property type should be this
.
@rbuckton I changed it, but now I'm not so sure... according to the linked spec, returning this is the default behavior, but subclasses are free to change that behavior. The only requirement is that it be call-compatible with the original constructor. This would be better modeled with the first commit. |
@NaridaL, you make a good point. I need to discuss with @DanielRosenwasser. Ideally you want |
After discussing with @DanielRosenwasser we should revert this back to the previous commit that used the explicit constructor type rather than |
80f087c
to
33344f9
Compare
@rbuckton Done. |
…r, ArrayBufferConstructor.
Fix Symbol.species in RegExpConstructor and PromiseConstructor.
See #2881 .