-
Notifications
You must be signed in to change notification settings - Fork 6.8k
chore: enable strict apply, bind, and call #18172
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
Conversation
@@ -1842,14 +1842,22 @@ describe('CdkDrag', () => { | |||
body: document.body, | |||
fullscreenElement: document.createElement('div'), | |||
ELEMENT_NODE: Node.ELEMENT_NODE, | |||
querySelectorAll: function() { | |||
return document.querySelectorAll.apply(document, arguments); | |||
querySelectorAll: function(...args: [string]) { |
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.
Shouldn't it be string[]
?
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.
string[]
is a string array of any length, [string]
is an array of exactly one string
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.
If we know it'll be one string, couldn't we just declare it like this?
querySelectorAll: (selector: string) {
return document.querySelectorAll.call(document, selector);
}
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.
My thinking was that for these ones where we're just wrapping a function and passing things through, the author was trying to be defensive against future browser API changes by just grabbing all of the arguments and shoving them through. This style preserves that
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.
I'm pretty sure that I'm the author and I think I did it because it was shorter 😄
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.
I can only speak for the ZoneJS interceptor, where I also did it that way. I wanted to be on the safe side if a different ZoneJS version is used / when the signature changes. The typings are manually copied, so not very reliable IMO.
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.
Yeah querySelectorAll
probably isn't going to change much, but some do, addEventListener
has definitely changed over the years
} | ||
}, | ||
querySelectorAll: function() { | ||
return document.querySelectorAll.apply(document, arguments); | ||
querySelectorAll: function(...args: [string]) { |
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.
Also should be string[]
? There are a few more changes like 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.
LGTM
I don't think the string[]
vs. [string]
matters much for our own unit tests
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.
LGTM
(cherry picked from commit 26962a7)
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
cc @mprobst