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

feat(dialog): ts conversion #4333

Merged
merged 13 commits into from
Feb 7, 2019
Merged

feat(dialog): ts conversion #4333

merged 13 commits into from
Feb 7, 2019

Conversation

moog16
Copy link
Contributor

@moog16 moog16 commented Feb 1, 2019

related #4225

@kfranqueiro kfranqueiro mentioned this pull request Feb 1, 2019
45 tasks
@acdvorak acdvorak self-assigned this Feb 6, 2019
@codecov-io
Copy link

codecov-io commented Feb 6, 2019

Codecov Report

Merging #4333 into feat/typescript will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##           feat/typescript    #4333      +/-   ##
===================================================
+ Coverage            98.52%   98.53%   +<.01%     
===================================================
  Files                   93       93              
  Lines                 5832     5851      +19     
  Branches               789      788       -1     
===================================================
+ Hits                  5746     5765      +19     
  Misses                  85       85              
  Partials                 1        1
Impacted Files Coverage Δ
packages/mdc-dialog/util.ts 100% <100%> (ø)
packages/mdc-dialog/foundation.ts 100% <100%> (ø)
packages/mdc-dialog/index.ts 100% <100%> (ø)

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 dc4e92c...a1cbcc4. Read the comment docs.

const isClick = evt.type === 'click';
const isEnter = evt.key === 'Enter' || evt.keyCode === 13;
const isEnter = (evt as KeyboardEvent).key === 'Enter' || (evt as KeyboardEvent).keyCode === 13;
Copy link
Contributor

Choose a reason for hiding this comment

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

Extract these checks to separate functions to make the code more readable. Ditto below.

Copy link
Contributor

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

Choose a reason for hiding this comment

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

Ken wasn't wild about extracting these out into util functions, so I reverted that change.

import {MDCRipple} from '@material/ripple/index';

import * as createFocusTrap from 'focus-trap';
Copy link
Contributor

Choose a reason for hiding this comment

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

Use two separate imports: one for the function, and one for the type definitions:

import createFocusTrap from 'focus-trap';
import * as FocusTrapLib from 'focus-trap';

Copy link
Contributor

Choose a reason for hiding this comment

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

Are you suggesting we shouldn't need to re-export FocusTrapLib from our own ./types (which is where we're currently importing it from)?

Copy link
Contributor

Choose a reason for hiding this comment

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

Turns out we need to do it this way:

import * as createFocusTrap from 'focus-trap';

// Function signature
createFocusTrap(...);

// Interface definitions
createFocusTrap.FocusTrap;
createFocusTrap.Options;

Although Focus Trap's .d.ts file claims to have a default export, default imports don't work:

import createFocusTrap from 'focus-trap';

// ERROR: undefined is not a function
createFocusTrap(...);

@mdc-web-bot
Copy link
Collaborator

All 621 screenshot tests passed for commit e339ccf vs. feat/typescript! 💯🎉

@mdc-web-bot
Copy link
Collaborator

All 621 screenshot tests passed for commit 19b28b5 vs. feat/typescript! 💯🎉

Copy link
Contributor

@acdvorak acdvorak left a comment

Choose a reason for hiding this comment

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

LGTM!

@mdc-web-bot
Copy link
Collaborator

All 621 screenshot tests passed for commit a1cbcc4 vs. feat/typescript! 💯🎉

@acdvorak acdvorak merged commit 33e26d7 into feat/typescript Feb 7, 2019
@acdvorak acdvorak deleted the feat/dialog-ts branch February 7, 2019 00:07
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