Skip to content

Commit c6cb074

Browse files
committed
Update mixins to avoid compilation issues
The following 2 issues appears internally: microsoft/TypeScript#15870 microsoft/TypeScript#9944 Change-Id: I60b669846447ff7f54e7b0f741402333c2b59653
1 parent 891eed0 commit c6cb074

File tree

4 files changed

+32
-6
lines changed

4 files changed

+32
-6
lines changed

polygerrit-ui/app/elements/shared/gr-autocomplete-dropdown/gr-autocomplete-dropdown.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {htmlTemplate} from './gr-autocomplete-dropdown_html';
2525
import {KeyboardShortcutMixin} from '../../../mixins/keyboard-shortcut-mixin/keyboard-shortcut-mixin';
2626
import {IronFitMixin} from '../../../mixins/iron-fit-mixin/iron-fit-mixin';
2727
import {customElement, property, observe} from '@polymer/decorators';
28+
import {IronFitBehavior} from '@polymer/iron-fit-behavior/iron-fit-behavior';
2829

2930
// TODO(TS): Update once GrCursorManager is upated
3031
export interface GrAutocompleteDropdown {
@@ -55,7 +56,8 @@ interface Item {
5556
export class GrAutocompleteDropdown extends IronFitMixin(
5657
KeyboardShortcutMixin(
5758
GestureEventListeners(LegacyElementMixin(PolymerElement))
58-
)
59+
),
60+
IronFitBehavior as IronFitBehavior
5961
) {
6062
static get template() {
6163
return htmlTemplate;

polygerrit-ui/app/elements/shared/gr-overlay/gr-overlay.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {PolymerElement} from '@polymer/polymer/polymer-element';
2121
import {htmlTemplate} from './gr-overlay_html';
2222
import {IronOverlayMixin} from '../../../mixins/iron-overlay-mixin/iron-overlay-mixin';
2323
import {customElement, property} from '@polymer/decorators';
24+
import {IronOverlayBehavior} from '@polymer/iron-overlay-behavior/iron-overlay-behavior';
2425

2526
const AWAIT_MAX_ITERS = 10;
2627
const AWAIT_STEP = 5;
@@ -34,7 +35,8 @@ declare global {
3435

3536
@customElement('gr-overlay')
3637
export class GrOverlay extends IronOverlayMixin(
37-
GestureEventListeners(LegacyElementMixin(PolymerElement))
38+
GestureEventListeners(LegacyElementMixin(PolymerElement)),
39+
IronOverlayBehavior as IronOverlayBehavior
3840
) {
3941
static get template() {
4042
return htmlTemplate;

polygerrit-ui/app/mixins/iron-fit-mixin/iron-fit-mixin.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,19 @@ import {Constructor} from '../../utils/common-util';
2222

2323
// The mixinBehaviors clears all type information about superClass.
2424
// As a workaround, we define IronFitMixin with correct type.
25+
// Due to the following issues:
26+
// https://github.com/microsoft/TypeScript/issues/15870
27+
// https://github.com/microsoft/TypeScript/issues/9944
28+
// we have to import IronFitBehavior in the same file where IronFitMixin
29+
// is used. To ensure that this import can't be avoided, the second parameter
30+
// is added. Usage example:
31+
// class Element extends IronFitMixin(PolymerElement, IronFitBehavior as IronFitBehavior)
32+
// The code 'IronFitBehavior as IronFitBehavior' required, becuase IronFitBehavior
33+
// defined as an object, not as IronFitBehavior instance.
34+
2535
export const IronFitMixin = <T extends Constructor<PolymerElement>>(
26-
superClass: T
36+
superClass: T,
37+
_: IronFitBehavior
2738
): T & Constructor<IronFitBehavior> =>
2839
// TODO(TS): mixinBehaviors in some lib is returning: `new () => T` instead
2940
// which will fail the type check due to missing IronFitBehavior interface

polygerrit-ui/app/mixins/iron-overlay-mixin/iron-overlay-mixin.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,20 @@ import {Constructor} from '../../utils/common-util';
2222

2323
// The mixinBehaviors clears all type information about superClass.
2424
// As a workaround, we define IronOverlayMixin with correct type.
25+
// Due to the following issues:
26+
// https://github.com/microsoft/TypeScript/issues/15870
27+
// https://github.com/microsoft/TypeScript/issues/9944
28+
// we have to import IronOverlayBehavior in the same file where IronOverlayMixin
29+
// is used. To ensure that this import can't be avoided, the second parameter
30+
// is added. Usage example:
31+
// class Element extends IronOverlayMixin(PolymerElement, IronOverlayBehavior as IronOverlayBehavior)
32+
// The code 'IronOverlayBehavior as IronOverlayBehavior' required, because
33+
// IronOverlayBehavior defined as an object, not as IronOverlayBehavior instance.
2534
export const IronOverlayMixin = <T extends Constructor<PolymerElement>>(
26-
superClass: T
35+
superClass: T,
36+
_: IronOverlayBehavior
2737
): T & Constructor<IronOverlayBehavior> =>
28-
// TODO(TS): mixinBehaviors in some lib is returning: `new () => T` instead
29-
// which will fail the type check due to missing IronOverlayBehavior interface
38+
// TODO(TS): mixinBehaviors in some lib is returning: `new () => T`
39+
// instead which will fail the type check due to missing
40+
// IronOverlayBehavior interface
3041
mixinBehaviors([IronOverlayBehavior], superClass) as any;

0 commit comments

Comments
 (0)