-
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(auto-init): Convert JS to TypeScript #4395
Conversation
Codecov Report
@@ Coverage Diff @@
## feat/typescript #4395 +/- ##
===================================================
+ Coverage 98.9% 98.93% +0.03%
===================================================
Files 95 95
Lines 6109 6102 -7
Branches 802 800 -2
===================================================
- Hits 6042 6037 -5
+ Misses 66 64 -2
Partials 1 1 Continue to review full report at Codecov.
|
All 621 screenshot tests passed for commit 4e99e51 vs. |
All 624 screenshot tests passed for commit e00153b vs. |
All 624 screenshot tests passed for commit 86a52f0 vs. |
All 624 screenshot tests passed for commit 6b6f7fb vs. |
All 624 screenshot tests passed for commit 78e0b7f vs. |
…an register custom components)
All 624 screenshot tests passed for commit 59adfbc vs. |
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.
One comment regarding an old TODO, otherwise LGTM
warn(`(mdc-auto-init) Component already initialized for ${node}. Skipping...`); | ||
continue; | ||
} | ||
|
||
// TODO: Should we make an eslint rule for an attachTo() static method? | ||
const component = Ctor.attachTo(node); | ||
// See https://github.com/Microsoft/TypeScript/issues/14600 for discussion of static interface support in TS |
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.
Is the TODO above this obsolete? (Like, would our build actually fail without an attachTo
given the typings above? Plus we're using tslint now to reuse the Google configuration.)
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.
Unfortunately TypeScript won't catch that because it doesn't do static type checking.
See microsoft/TypeScript#14600.
attachTo()
in the Component
interface is only there to make TS happy when we try to call Constructor.attachTo()
in mdcAutoInit()
. It doesn't verify that static attachTo()
exists on classes passed to register()
.
It does, however, verify that the required constructor signature exists (via new<F...>()
) on classes passed to register()
.
All 624 screenshot tests passed for commit 8aae7e3 vs. |
All 624 screenshot tests passed for commit 5d3f489 vs. |
Refs #4225