Convert gr-diff-host to typescript
The change converts the following files to typescript:
* elements/diff/gr-diff-host/gr-diff-host.ts
Change-Id: Ie565ab753fea6909790729b8e42410d39c437612
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
index 0aa42c3..8984dc8 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff-utils.ts
@@ -18,17 +18,12 @@
import {CommentRange} from '../../../types/common';
import {FILE, LineNumber} from './gr-diff-line';
-export enum DiffSide {
- LEFT = 'left',
- RIGHT = 'right',
-}
-
/**
* Compare two ranges. Either argument may be falsy, but will only return
* true if both are falsy or if neither are falsy and have the same position
* values.
*/
-export function rangesEqual(a: CommentRange, b: CommentRange): boolean {
+export function rangesEqual(a?: CommentRange, b?: CommentRange): boolean {
if (!a && !b) {
return true;
}
diff --git a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts
index 8ac47a2..159c056 100644
--- a/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts
+++ b/polygerrit-ui/app/elements/diff/gr-diff/gr-diff.ts
@@ -27,7 +27,7 @@
import {LegacyElementMixin} from '@polymer/polymer/lib/legacy/legacy-element-mixin';
import {htmlTemplate} from './gr-diff_html';
import {FILE, LineNumber} from './gr-diff-line';
-import {DiffSide, getLineNumber, rangesEqual} from './gr-diff-utils';
+import {getLineNumber, rangesEqual} from './gr-diff-utils';
import {getHiddenScroll} from '../../../scripts/hiddenscroll';
import {isMergeParent, patchNumEquals} from '../../../utils/patch-set-util';
import {customElement, observe, property} from '@polymer/decorators';
@@ -95,7 +95,7 @@
const RENDER_DIFF_TABLE_DEBOUNCE_NAME = 'renderDiffTable';
-interface LineOfInterest {
+export interface LineOfInterest {
number: number;
leftSide: boolean;
}
@@ -534,7 +534,7 @@
this.dispatchEvent(
new CustomEvent('line-selected', {
detail: {
- side: el.classList.contains('left') ? DiffSide.LEFT : DiffSide.RIGHT,
+ side: el.classList.contains('left') ? Side.LEFT : Side.RIGHT,
number: el.getAttribute('data-value'),
path: this.path,
},
@@ -614,7 +614,7 @@
);
return false;
}
- const patchNum = el.classList.contains(DiffSide.LEFT)
+ const patchNum = el.classList.contains(Side.LEFT)
? this.patchRange.basePatchNum
: this.patchRange.patchNum;
@@ -717,7 +717,7 @@
let patchNum = this.patchRange.patchNum;
if (
- (lineEl.classList.contains(DiffSide.LEFT) ||
+ (lineEl.classList.contains(Side.LEFT) ||
contentEl.classList.contains('remove')) &&
this.patchRange.basePatchNum !== 'PARENT' &&
!isMergeParent(this.patchRange.basePatchNum)
@@ -730,7 +730,7 @@
_getIsParentCommentByLineAndContent(lineEl: Element, contentEl: Element) {
if (!this.patchRange) throw Error('patch range not set');
return (
- (lineEl.classList.contains(DiffSide.LEFT) ||
+ (lineEl.classList.contains(Side.LEFT) ||
contentEl.classList.contains('remove')) &&
(this.patchRange.basePatchNum === 'PARENT' ||
isMergeParent(this.patchRange.basePatchNum))
@@ -740,7 +740,7 @@
_getCommentSideByLineAndContent(lineEl: Element, contentEl: Element): Side {
let side = Side.RIGHT;
if (
- lineEl.classList.contains(DiffSide.LEFT) ||
+ lineEl.classList.contains(Side.LEFT) ||
contentEl.classList.contains('remove')
) {
side = Side.LEFT;