Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

feat(tabs): Convert JS to TypeScript #4412

Merged
merged 21 commits into from
Feb 15, 2019
Merged

Conversation

acdvorak
Copy link
Contributor

Refs #4225

@mdc-web-bot
Copy link
Collaborator

All 624 screenshot tests passed for commit 338a9cd vs. feat/typescript! 💯🎉

@mdc-web-bot
Copy link
Collaborator

All 624 screenshot tests passed for commit 12ddf9d vs. feat/typescript! 💯🎉

@mdc-web-bot
Copy link
Collaborator

All 624 screenshot tests passed for commit 6cf5ef1 vs. feat/typescript! 💯🎉

@codecov-io
Copy link

codecov-io commented Feb 14, 2019

Codecov Report

Merging #4412 into feat/typescript will increase coverage by 0.02%.
The diff coverage is 100%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feat/typescript    #4412      +/-   ##
===================================================
+ Coverage            99.03%   99.05%   +0.02%     
===================================================
  Files                   95       98       +3     
  Lines                 6110     6166      +56     
  Branches               804      808       +4     
===================================================
+ Hits                  6051     6108      +57     
+ Misses                  58       57       -1     
  Partials                 1        1
Impacted Files Coverage Δ
packages/mdc-tabs/tab/index.ts 100% <100%> (ø)
packages/mdc-tabs/tab/component.ts 94.87% <100%> (ø)
packages/mdc-tabs/tab-bar/index.ts 100% <100%> (ø)
packages/mdc-tabs/tab/foundation.ts 100% <100%> (ø)
packages/mdc-tabs/tab-bar-scroller/index.ts 100% <100%> (ø)
packages/mdc-tabs/tab-bar/component.ts 100% <100%> (ø)
packages/mdc-tabs/tab-bar-scroller/foundation.ts 100% <100%> (ø)
packages/mdc-tabs/tab-bar-scroller/component.ts 100% <100%> (ø)
packages/mdc-tabs/tab-bar/foundation.ts 100% <100%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03b791d...0a523d0. Read the comment docs.

packages/mdc-tabs/tab-bar-scroller/component.ts Outdated Show resolved Hide resolved
packages/mdc-tabs/tab-bar/component.ts Outdated Show resolved Hide resolved
packages/mdc-tabs/tab-bar/foundation.ts Outdated Show resolved Hide resolved
packages/mdc-tabs/tab-bar/foundation.ts Show resolved Hide resolved
@mdc-web-bot
Copy link
Collaborator

All 624 screenshot tests passed for commit 85d518e vs. feat/typescript! 💯🎉

@mdc-web-bot
Copy link
Collaborator

All 624 screenshot tests passed for commit 69d249f vs. feat/typescript! 💯🎉

packages/mdc-tabs/tab-bar-scroller/adapter.ts Outdated Show resolved Hide resolved
this.tabBar_ = tabBarFactory(this.tabBarEl_);
}

getDefaultFoundation() {
return new MDCTabBarScrollerFoundation({
// tslint:disable:object-literal-sort-keys
const adapter: MDCTabBarScrollerAdapter = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious why you have separate const adapter here whereas in others we've just written the adapter implementation inline? Did this need to be explicitly typed for some reason?

Same for TabBar

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The foundation argument is a Partial<MDCFooAdapter>, so tsc won't complain if we omit a method; it'll just merge it with the default implementation, which does nothing. This ensures that we'll get a compiler error if we forget a field.

registerCapturedInteractionHandler: (evt, handler) =>
this.root_.addEventListener(evt, handler, true),
this.root_.addEventListener(evt, handler as EventListener, true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these consistent with how we've done them in other components? E.g. in checkbox and form field it looks like we specified types for the parameters... in floating label it looks like we didn't have to. So I'm a little confused... maybe this is something to revisit separately across packages anyway...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you clarify? Which parameter types are you referring to in checkbox and form-field?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need cast this or the deregister method

Copy link
Contributor

@kfranqueiro kfranqueiro Feb 15, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm. I may have been looking in different contexts for checkbox and form field. Form field and floating label don't appear to use casts at all.

deregisterInteractionHandler: (evtType, handler) => {
if (this.label_) {
this.label_.removeEventListener(evtType, handler);
}
},
registerInteractionHandler: (evtType, handler) => {
if (this.label_) {
this.label_.addEventListener(evtType, handler);
}

registerInteractionHandler: (evtType, handler) => this.root_.addEventListener(evtType, handler),
deregisterInteractionHandler: (evtType, handler) => this.root_.removeEventListener(evtType, handler),

Meanwhile checkbox does this in its overrides for ripple's adapter:

registerInteractionHandler: <K extends EventType>(evtType: K, handler: SpecificEventListener<K>) =>

Although ripple itself doesn't seem to involve any casts or generics either:

registerInteractionHandler: (evtType, handler) =>
instance.root_.addEventListener(evtType, handler, util.applyPassive()),

So I'm probably looking at all of these out of context but I'm wondering why they seem inconsistent.

packages/mdc-tabs/tab-bar-scroller/index.ts Outdated Show resolved Hide resolved
packages/mdc-tabs/tab-bar-scroller/adapter.ts Show resolved Hide resolved
packages/mdc-tabs/tab-bar/component.ts Outdated Show resolved Hide resolved
packages/mdc-tabs/tab/adapter.ts Outdated Show resolved Hide resolved
packages/mdc-tabs/tab-bar-scroller/foundation.ts Outdated Show resolved Hide resolved
packages/mdc-tabs/tab-bar/foundation.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@moog16 moog16 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert package-lock changes as well.

packages/mdc-tabs/tab-bar-scroller/component.ts Outdated Show resolved Hide resolved
registerCapturedInteractionHandler: (evt, handler) =>
this.root_.addEventListener(evt, handler, true),
this.root_.addEventListener(evt, handler as EventListener, true),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need cast this or the deregister method

packages/mdc-tabs/tab-bar-scroller/foundation.ts Outdated Show resolved Hide resolved
@acdvorak acdvorak merged commit 409a6a6 into feat/typescript Feb 15, 2019
@acdvorak acdvorak deleted the feat/typescript--tabs branch February 15, 2019 18:58
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants