Skip to content
This repository was archived by the owner on Dec 19, 2024. It is now read-only.

Add TypeScript declarations to iron-overlay-behavior. #261

Merged
merged 10 commits into from
Feb 7, 2018

Conversation

aomarks
Copy link
Contributor

@aomarks aomarks commented Feb 2, 2018

This PR adds TypeScript declarations generated by https://github.com/Polymer/gen-typescript-declarations/

These declarations can be re-generated by running npm run update-types.

Tracker: https://github.com/Polymer/gen-typescript-declarations/issues/79

/**
* The backdrop element.
*/
backdropElement(): any;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Looks like we're sometimes using the @type annotation for getters, but it should be @return. Updated. Also updated the other cases I found.

/**
* Returns the node to give focus to.
*/
_focusNode(): any;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

* If you know what is your content (specifically the first and last focusable children),
* you can override this method to return only `[firstFocusable, lastFocusable];`
*/
_focusableNodes(): any;
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done. Actually it should be !Array<!Node> or else it would be a nullable array of nullable nodes, since non-primitive types are nullable by default in Closure. Updated the other cases I found too.

interface IronOverlayBehavior {
}

const IronOverlayBehavior: object;
Copy link
Member

Choose a reason for hiding this comment

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

how is it expressed that IronOverlayBehavior is composed by other behaviors?
https://github.com/PolymerElements/iron-overlay-behavior/blob/master/iron-overlay-behavior.html#L796

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Huh, that's a good catch. We don't handle behavior arrays right now. Filed https://github.com/Polymer/gen-typescript-declarations/issues/80 and will update this PR when done.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Updated to add the other behaviors. See interface above.

* Will call notifyResize if overlay is opened.
* Can be overridden in order to avoid multiple observers on the same node.
*/
_onNodesChange(): any;
Copy link
Member

Choose a reason for hiding this comment

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

is _manager property being omitted on purpose because it's private?
https://github.com/PolymerElements/iron-overlay-behavior/blob/master/iron-overlay-behavior.html#L132

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we don't emit private things.

@@ -56,6 +56,7 @@
/**
* The current element that defines the DOM boundaries of the
* scroll lock. This is always the most recently locking element.
* @return {!Node}
Copy link
Member

Choose a reason for hiding this comment

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

currentLockingElement can be undefined - this was wrongly annotated previously as it was saying that currentLockingElement can be null

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@aomarks aomarks requested a review from dfreedm as a code owner February 6, 2018 04:28
Copy link
Contributor

@dfreedm dfreedm left a comment

Choose a reason for hiding this comment

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

LGTM, though it would be nice to not have to duplicate the escape codes and message for each element.

@aomarks
Copy link
Contributor Author

aomarks commented Feb 6, 2018

LGTM, though it would be nice to not have to duplicate the escape codes and message for each element.

I'll update the tedium script to do this for all the repos (PolymerLabs/tedium#63), although did you have something else in mind? I guess I could make the generator itself have a flag that errors if anything has changed?

@aomarks aomarks force-pushed the gen-typescript-declarations branch from 091dc84 to 8a5d32f Compare February 7, 2018 00:43
@@ -0,0 +1,12 @@
/**
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@valdrinkoshi Is IronFocusablesHelper supposed to be something users use, or is it fine that this file is empty? It doesn't have any annotations, so analyzer doesn't pick it up as an interesting feature. Same question for IronScrollManager.

Copy link
Member

Choose a reason for hiding this comment

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

All managers/helpers are singletons available on window and expose public methods, so can be used by users: IronFocusablesHelper, IronOverlayManager, IronScrollManager
I'm sure users rely on the public methods of IronFocusablesHelper and IronOverlayManager as they're been around for a while.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added some annotations to generate IronScrollManager, although it is missing a getter. IronOverlayManager is probably too difficult for Analyzer to understand at all right now. Filed #262 with details on both.

I'd like to merge this PR despite these missing types, because this element is a dependency of a lot of other ones. I'd like to go back and add some manual typings for the managers a bit later, if that's ok.

@valdrinkoshi
Copy link
Member

Sounds good, LGTM

@aomarks aomarks merged commit b7afaae into master Feb 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants