-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
feat(text-field): Convert JS to TypeScript #4377
Conversation
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.
Partial review to send comments so far.
cea3fad
to
3e01b8c
Compare
Codecov Report
@@ Coverage Diff @@
## feat/typescript #4377 +/- ##
===================================================
+ Coverage 98.68% 98.85% +0.17%
===================================================
Files 94 94
Lines 5987 6051 +64
Branches 805 810 +5
===================================================
+ Hits 5908 5982 +74
+ Misses 78 68 -10
Partials 1 1
Continue to review full report at Codecov.
|
All 624 screenshot tests passed for commit 8e34f91 vs. |
All 624 screenshot tests passed for commit 44f2987 vs. |
All 624 screenshot tests passed for commit 1c78cf6 vs. |
All 624 screenshot tests passed for commit 730164d vs. |
All 624 screenshot tests passed for commit 1d88400 vs. |
*/ | ||
isNativeInputValid_() { | ||
private isBadInput_(): boolean { | ||
// The badInput property is not supported in IE 11 💩. |
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 dunno how we feel about your autocompleted emoji ending up in source :P
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.
Hah I guess I've gotten used to it and didn't even notice... Personally I think it's hilarious and fitting, but I can remove it if you really want 😛
private input_!: HTMLInputElement; // assigned in initialize() | ||
|
||
// Optional sub-elements. | ||
private characterCounter_!: MDCTextFieldCharacterCounter | null; // assigned in initialize() |
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 notice all of these are !
and | null
, but you also replaced the if
s below in initialize
with ternary expressions. Could these be ?
(and not require | null
) if we left initialize
more intact with if
s? Did doing it this way make anything easier?
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.
Using null
just made the code a little cleaner by condensing the if
statements down to ternaries. That's the only reason I did it 😄
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 guess since they're all private it doesn't really matter either way. I'm not sure if there's any perception that one is preferable over the other, typing-wise, other than ?
existing as a more concise representation of | undefined
.
test/unit/mdc-textfield/mdc-text-field-character-counter-foundation.test.js
Outdated
Show resolved
Hide resolved
All 624 screenshot tests passed for commit 530c4c6 vs. |
All 624 screenshot tests passed for commit be64af2 vs. |
import {MDCTextFieldIconFoundation} from './icon/foundation'; | ||
import {MDCTextFieldIcon} from './icon/index'; | ||
|
||
export type NativeInputElement = Pick<HTMLInputElement, 'disabled' | 'maxLength' | 'type' | 'value'> & { |
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.
NICE
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.
Thanks for the suggestion! 🎉 🌮
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 left two comments, but I they are just stylistic. looks good!
All 624 screenshot tests passed for commit c405d56 vs. |
All 624 screenshot tests passed for commit 03f0022 vs. |
Addressed Ken's concerns about unit tests; approved by Matt
Refs #4225