Skip to content
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

Convert services to TypeScript, part 2 #1392

Merged
merged 11 commits into from
Jan 3, 2019

Conversation

pugnascotia
Copy link
Contributor

@pugnascotia pugnascotia commented Dec 20, 2018

Summary

Follow-up to #1360. Convert the remaining half of services to TypeScript. Notes:

  • I tweaked the proptypes-from-ts-props Babel plugin to work around index signatures in interfaces.
  • The popover code was a bit of a beast to convert. I tried to introduce sane interfaces, but I'd appreciate more eyes on it. Better names would be nice.
  • I moved the export of Query and Ast from services to the components tree. As far as I can tell, the export from services is hangover from a reverted attempt to move some of the query code to services, and it was preventing the move of services/index.js to TS.
  • Run the build in CI, in case it breaks due to scripting changes.

Checklist

  • This was checked in mobile
  • This was checked in IE11
  • This was checked in dark mode
  • Any props added have proper autodocs
  • Documentation examples were added
  • A changelog entry exists and is marked appropriately
  • This was checked for breaking changes and labeled appropriately
  • Jest tests were updated or added to match the most common scenarios
  • This was checked against keyboard-only and screenreader scenarios
  • This required updates to Framer X components

@@ -377,8 +447,6 @@ function getCrossAxisPosition({
let crossAxisArrowPosition;
if (arrowConfig) {
const { arrowWidth } = arrowConfig;
const anchorSizeOnCrossAxis = anchorBoundingBox[crossAxisDimension];
const anchorHalfSize = anchorSizeOnCrossAxis / 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAICT these lines were recalculating some values for no reason.

componentDidMount() {
this.addEvent(this.props);
}

componentDidUpdate(prevProps) {
componentDidUpdate(prevProps: Props<E>) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't actually true, since the props could change to that we're handing a different event type. The types here are intended to ensure that the event type in the callback matches the event name, but that ends up leaking into the class' generic type. If the component instance receives different props, it can end up wrapping a different event type. In practice this may not be an issue?

@pugnascotia
Copy link
Contributor Author

@chandlerprall the build is breaking - would you mind taking a look? I added a change to this PR so that CI runs the build (it should have been doing that anyway), so the CI logs will show what broke. Seems to be duplicate declarations in eui.d.ts.

@snide
Copy link
Contributor

snide commented Dec 20, 2018

@pugnascotia Just a heads up. Chandler is out for break. The good news is we have a new engineer joining the EUI team starting in January who can give us some more coverage here. If you're in a hury, you might want to ping one of the Cloud or Kibana devs to give you a proper review since this one is a bit too intense for Caroline or I :)

That popover stuff can be difficult so it might just be best to wait till Jan on this one.

@pugnascotia
Copy link
Contributor Author

What a slacker! 😁

done();
}, 8);
});
});

describe('pause', () => {
test('stops timer', done => {
const callbackSpy = sinon.spy();
const callbackSpy = jest.fn();
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for converting these to jest's mock functions!

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

This looks fantastic @pugnascotia , thank you! I'm looking into the issue with exported types.

@pugnascotia
Copy link
Contributor Author

Thanks for the fix @chandlerprall, I've rebased on the laster master so this is good to review.

Copy link
Contributor

@chandlerprall chandlerprall left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for converting all the services!

@pugnascotia pugnascotia merged commit 121101f into elastic:master Jan 3, 2019
@pugnascotia pugnascotia deleted the convert-services-to-ts-pt2 branch January 3, 2019 17:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants