Convert files to typescript

The change converts the following files to typescript:

* elements/gr-app-element.ts
* elements/gr-app.ts

Additionally, this change turns off the goog-module-id rule - it is
not required anymore (migration to typescript is almost complete).

Change-Id: I5f0845c03a464322500113b978722a12da7afdee
diff --git a/polygerrit-ui/app/types/events.ts b/polygerrit-ui/app/types/events.ts
new file mode 100644
index 0000000..ef0515e
--- /dev/null
+++ b/polygerrit-ui/app/types/events.ts
@@ -0,0 +1,162 @@
+/**
+ * @license
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import {EventApi} from '@polymer/polymer/lib/legacy/polymer.dom';
+import {PatchSetNum} from './common';
+import {UIComment} from '../utils/comment-util';
+
+export interface TitleChangeEventDetail {
+  title: string;
+}
+
+export type TitleChangeEvent = CustomEvent<TitleChangeEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'title-change': TitleChangeEvent;
+  }
+}
+
+export interface PageErrorEventDetail {
+  response: Response;
+}
+
+export type PageErrorEvent = CustomEvent<PageErrorEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'page-error': PageErrorEvent;
+  }
+}
+
+export interface LocationChangeEventDetail {
+  hash: string;
+  pathname: string;
+}
+
+export type LocationChangeEvent = CustomEvent<LocationChangeEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'location-change': LocationChangeEvent;
+  }
+}
+
+export interface RpcLogEventDetail {
+  status: number | null;
+  method: string;
+  elapsed: number;
+  anonymizedUrl: string;
+}
+
+export type RpcLogEvent = CustomEvent<RpcLogEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'rpc-log': RpcLogEvent;
+  }
+}
+
+export interface ShortcutTriggeredEventDetail {
+  event: CustomKeyboardEvent;
+  goKey: boolean;
+  vKey: boolean;
+}
+
+export type ShortcutTriggeredEvent = CustomEvent<ShortcutTriggeredEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'shortcut-triggered': ShortcutTriggeredEvent;
+  }
+}
+
+export interface EditableContentSaveEventDetail {
+  content: string;
+}
+
+export type EditableContentSaveEvent = CustomEvent<
+  EditableContentSaveEventDetail
+>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'editable-content-save': EditableContentSaveEvent;
+  }
+}
+
+export interface OpenFixPreviewEventDetail {
+  patchNum?: PatchSetNum;
+  comment?: UIComment;
+}
+
+export type OpenFixPreviewEvent = CustomEvent<OpenFixPreviewEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'open-fix-preview': OpenFixPreviewEvent;
+  }
+}
+
+// Type for the custom event to switch tab.
+interface SwitchTabEventDetail {
+  // name of the tab to set as active, from custom event
+  tab?: string;
+  // index of tab to set as active, from paper-tabs event
+  value?: number;
+  // scroll into the tab afterwards, from custom event
+  scrollIntoView?: boolean;
+}
+
+export type SwitchTabEvent = CustomEvent<SwitchTabEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    'show-primary-tab': SwitchTabEvent;
+    'show-secondary-tab': SwitchTabEvent;
+  }
+}
+
+export interface ReloadEventDetail {
+  clearPatchset: boolean;
+}
+
+export type ReloadEvent = CustomEvent<ReloadEventDetail>;
+
+declare global {
+  interface HTMLElementEventMap {
+    reload: ReloadEvent;
+  }
+}
+
+/**
+ * Keyboard events emitted from polymer elements.
+ */
+export interface CustomKeyboardEvent extends CustomEvent, EventApi {
+  event: CustomKeyboardEvent;
+  detail: {
+    keyboardEvent?: CustomKeyboardEvent;
+    // TODO(TS): maybe should mark as optional and check before accessing
+    key: string;
+  };
+  readonly altKey: boolean;
+  readonly changedTouches: TouchList;
+  readonly ctrlKey: boolean;
+  readonly metaKey: boolean;
+  readonly shiftKey: boolean;
+  readonly keyCode: number;
+  readonly repeat: boolean;
+}
diff --git a/polygerrit-ui/app/types/globals.ts b/polygerrit-ui/app/types/globals.ts
index 1b5f330..d383c4d 100644
--- a/polygerrit-ui/app/types/globals.ts
+++ b/polygerrit-ui/app/types/globals.ts
@@ -56,6 +56,8 @@
       dashboardQuery?: string[];
     };
 
+    VERSION_INFO?: string;
+
     /** Enhancements on Gr elements or utils */
     // TODO(TS): should clean up those and removing them may break certain plugin behaviors
     // TODO(TS): as @brohlfs suggested, to avoid importing anything from elements/ to types/
@@ -116,4 +118,11 @@
       usedJSHeapSize: number;
     };
   }
+
+  interface Event {
+    // path is a non-standard property. Actually, this is optional property,
+    // but marking it as optional breaks CustomKeyboardEvent
+    // TODO(TS): replace with composedPath if possible
+    readonly path: EventTarget[];
+  }
 }
diff --git a/polygerrit-ui/app/types/types.ts b/polygerrit-ui/app/types/types.ts
index 3bb8e37..b40d618 100644
--- a/polygerrit-ui/app/types/types.ts
+++ b/polygerrit-ui/app/types/types.ts
@@ -19,7 +19,13 @@
 import {GrDiffLine} from '../elements/diff/gr-diff/gr-diff-line';
 import {FlattenedNodesObserver} from '@polymer/polymer/lib/utils/flattened-nodes-observer';
 import {PaperInputElement} from '@polymer/paper-input/paper-input';
-import {CommitId, NumericChangeId, PatchRange, PatchSetNum} from './common';
+import {
+  ChangeId,
+  CommitId,
+  NumericChangeId,
+  PatchRange,
+  PatchSetNum,
+} from './common';
 import {PolymerSpliceChange} from '@polymer/polymer/interfaces';
 
 export function notUndefined<T>(x: T | undefined): x is T {
@@ -175,13 +181,23 @@
   showDownloadDialog: boolean;
   diffMode: DiffViewMode | null;
   numFilesShown: number | null;
-  scrollTop: number;
+  scrollTop?: number;
+  diffViewMode?: boolean;
 }
 
 export interface ChangeListViewState {
-  query: string | null;
-  offset: number;
-  selectedChangeIndex: number;
+  changeNum?: ChangeId;
+  patchRange?: PatchRange;
+  // TODO(TS): seems only one of 2 selected... is required
+  selectedFileIndex?: number;
+  selectedChangeIndex?: number;
+  showReplyDialog?: boolean;
+  showDownloadDialog?: boolean;
+  diffMode?: DiffViewMode;
+  numFilesShown?: number;
+  scrollTop?: number;
+  query?: string | null;
+  offset?: number;
 }
 
 export interface DashboardViewState {