Convert files to typescript

The change converts the following files to typescript:

* elements/diff/gr-apply-fix-dialog/gr-apply-fix-dialog.ts

Change-Id: I274ba656285897c89c42f299724e402758b8cfe3
diff --git a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
index bc7e739..f1af68d 100644
--- a/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
+++ b/polygerrit-ui/app/elements/shared/gr-comment/gr-comment.ts
@@ -49,6 +49,7 @@
   CommentInfo,
   ConfigInfo,
   AccountDetailInfo,
+  ChangeNum,
 } from '../../../types/common';
 import {GrButton} from '../gr-button/gr-button';
 import {GrConfirmDeleteCommentDialog} from '../gr-confirm-delete-comment-dialog/gr-confirm-delete-comment-dialog';
@@ -96,6 +97,10 @@
 export type Comment = Draft & CommentInfo;
 export type RobotComment = Draft & RobotCommentInfo;
 
+export function isRobotComment(c: Comment | RobotComment): c is RobotComment {
+  return (c as RobotComment).robot_id !== undefined;
+}
+
 interface CommentOverlays {
   confirmDelete?: GrOverlay | null;
   confirmDiscard?: GrOverlay | null;
@@ -109,6 +114,12 @@
     resolvedCheckbox: HTMLInputElement;
   };
 }
+
+export interface CommentEventDetail {
+  patchNum?: PatchSetNum;
+  comment?: Comment | RobotComment;
+}
+
 @customElement('gr-comment')
 export class GrComment extends KeyboardShortcutMixin(
   GestureEventListeners(LegacyElementMixin(PolymerElement))
@@ -160,7 +171,7 @@
    */
 
   @property({type: Number})
-  changeNum?: number;
+  changeNum?: ChangeNum;
 
   @property({type: Object, notify: true, observer: '_commentChanged'})
   comment?: Comment | RobotComment;
@@ -506,8 +517,8 @@
     );
   }
 
-  _getEventPayload(opt_mixin?: Record<string, any>) {
-    return {...opt_mixin, comment: this.comment, patchNum: this.patchNum};
+  _getEventPayload(): CommentEventDetail {
+    return {comment: this.comment, patchNum: this.patchNum};
   }
 
   _fireSave() {
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts
index 944c0a7..b3dba32 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-rest-api-interface.ts
@@ -130,6 +130,9 @@
   SubmittedTogetherInfo,
   ChangeNum,
   EmailAddress,
+  FixId,
+  FilePathToDiffInfoMap,
+  ChangeViewChangeInfo,
 } from '../../../types/common';
 import {
   CancelConditionCallback,
@@ -1388,7 +1391,11 @@
         optionsHex,
         errFn,
         cancelCondition
-      ).then(GrReviewerUpdatesParser.parse);
+      ).then(detail =>
+        // detail has ChangeViewChangeInfo type because the optionsHex always
+        // includes ALL_REVISIONS flag.
+        GrReviewerUpdatesParser.parse(detail as ChangeViewChangeInfo)
+      );
     });
   }
 
@@ -2329,21 +2336,21 @@
   getRobotCommentFixPreview(
     changeNum: ChangeNum,
     patchNum: PatchSetNum,
-    fixId: string
-  ) {
+    fixId: FixId
+  ): Promise<FilePathToDiffInfoMap | undefined> {
     return this._getChangeURLAndFetch({
       changeNum,
       patchNum,
       endpoint: `/fixes/${encodeURIComponent(fixId)}/preview`,
       reportEndpointAsId: true,
-    });
+    }) as Promise<FilePathToDiffInfoMap | undefined>;
   }
 
   applyFixSuggestion(
     changeNum: ChangeNum,
     patchNum: PatchSetNum,
     fixId: string
-  ) {
+  ): Promise<Response> {
     return this._getChangeURLAndSend({
       method: HttpMethod.POST,
       changeNum,
diff --git a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts
index 2c3bf44..b5e5696 100644
--- a/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts
+++ b/polygerrit-ui/app/elements/shared/gr-rest-api-interface/gr-reviewer-updates-parser.ts
@@ -21,6 +21,7 @@
   AccountInfo,
   ChangeInfo,
   ChangeMessageInfo,
+  ChangeViewChangeInfo,
   ReviewerUpdateInfo,
   Timestamp,
 } from '../../../types/common';
@@ -30,7 +31,7 @@
 const MESSAGE_REVIEWERS_THRESHOLD_MILLIS = 500;
 const REVIEWER_UPDATE_THRESHOLD_MILLIS = 6000;
 
-interface ChangeInfoParserInput extends ChangeInfo {
+interface ChangeInfoParserInput extends ChangeViewChangeInfo {
   messages: ChangeMessageInfo[];
   reviewer_updates: ReviewerUpdateInfo[]; // Always has at least 1 item
 }
@@ -77,7 +78,8 @@
   prev_state?: ReviewerState;
 }
 
-export interface ParsedChangeInfo extends Omit<ChangeInfo, 'reviewer_updates'> {
+export interface ParsedChangeInfo
+  extends Omit<ChangeViewChangeInfo, 'reviewer_updates'> {
   reviewer_updates?: ReviewerUpdateInfo[] | FormattedReviewerUpdateInfo[];
 }
 
@@ -291,7 +293,7 @@
   }
 
   static parse(
-    change: ChangeInfo | undefined | null
+    change: ChangeViewChangeInfo | undefined | null
   ): ParsedChangeInfo | undefined | null {
     // TODO(TS): The !change condition should be removed when all files are converted to TS
     if (!change || !isChangeInfoParserInput(change)) {