Conversation
changelog: Internal, Code Quality, Convert JavaScript to TypeScript
aduth
commented
Jul 18, 2023
| const inputs = document.querySelectorAll('input.ssn-toggle[type="password"]'); | ||
| const inputs = document.querySelectorAll<HTMLInputElement>('input.ssn-toggle[type="password"]'); | ||
|
|
||
| if (inputs) { |
Contributor
Author
There was a problem hiding this comment.
Future refactoring opportunity: This condition is unnecessary since the return value of querySelectorAll will always be truthy, even if the result is empty.
!![] === true| toggle.addEventListener('change', sync); | ||
|
|
||
| function limitLength() { | ||
| function limitLength(this: HTMLInputElement) { |
Contributor
Author
There was a problem hiding this comment.
Future refactoring opportunity: this is probably more trouble than it's worth, and we could either pass input as a parameter or reference input directly from the parent scope.
zachmargolis
approved these changes
Jul 18, 2023
| if (inputs) { | ||
| [].slice.call(inputs).forEach((input) => { | ||
| const toggle = document.querySelector(`[aria-controls="${input.id}"]`); | ||
| inputs.forEach((input) => { |
Contributor
There was a problem hiding this comment.
did inputs have forEach all along? or was this something we get as part of dropping IE?
Contributor
Author
There was a problem hiding this comment.
This is possible because of dropping IE: https://caniuse.com/mdn-api_nodelist_foreach
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🛠 Summary of changes
Continues to chip away at our remaining
tsconfig.jsonexcludesexceptions for TypeScript, by portingssn-field.jsto TypeScript.There are more refactoring opportunities with this file, but I kept the changes limited for review sake:
📜 Testing Plan
Verify no regressions in the behavior of SSN field formatting.