[OOBE] Migrate user_allowlist_check_screen to TS

Bug: b:314761865
Change-Id: I4af5b7663f51417709d401f0a01fe253ad02d1f8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/5193006
Commit-Queue: Brahim Chikhaoui <bchikhaoui@google.com>
Reviewed-by: Danila Kuzmin <dkuzmin@google.com>
Cr-Commit-Position: refs/heads/main@{#1247573}
diff --git a/chrome/browser/resources/chromeos/login/login.gni b/chrome/browser/resources/chromeos/login/login.gni
index c7f966c..792e33e 100644
--- a/chrome/browser/resources/chromeos/login/login.gni
+++ b/chrome/browser/resources/chromeos/login/login.gni
@@ -150,7 +150,7 @@
   "screens/common/theme_selection.ts",
   "screens/common/touchpad_scroll.js",
   "screens/common/tpm_error.ts",
-  "screens/common/user_allowlist_check_screen.js",
+  "screens/common/user_allowlist_check_screen.ts",
   "screens/common/user_creation.ts",
   "screens/common/wrong_hwid.ts",
 ]
diff --git a/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.html b/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.html
index d7700ae..cc0701a 100644
--- a/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.html
+++ b/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.html
@@ -5,9 +5,9 @@
 -->
 
 <notification-card id="gaia-allowlist-error" class="fit" for-step="default"
-  on-buttonclick="onAllowlistErrorTryAgainClick_"
-  on-linkclick="onAllowlistErrorLinkClick_"
+  on-buttonclick="onAllowlistErrorTryAgainClick"
+  on-linkclick="onAllowlistErrorLinkClick"
   button-label="[[i18nDynamic(locale, 'tryAgainButton')]]"
   link-label="[[i18nDynamic(locale, 'learnMoreButton')]]">
-  [[i18nDynamic(locale, allowlistError_)]]
+  [[i18nDynamic(locale, allowlistError)]]
 </notification-card>
diff --git a/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.js b/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.js
deleted file mode 100644
index 2a53ff5..0000000
--- a/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.js
+++ /dev/null
@@ -1,123 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview Oobe signin screen implementation.
- */
-
-
-import '../../components/notification_card.js';
-
-import {assert} from '//resources/ash/common/assert.js';
-import {html, mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js';
-
-import {LoginScreenBehavior, LoginScreenBehaviorInterface} from '../../components/behaviors/login_screen_behavior.js';
-import {MultiStepBehavior, MultiStepBehaviorInterface} from '../../components/behaviors/multi_step_behavior.js';
-import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
-
-import {getTemplate} from './user_allowlist_check_screen.html.js';
-
-// The help topic regarding user not being in the allowlist.
-const HELP_CANT_ACCESS_ACCOUNT = 188036;
-
-/**
- * UI mode for the dialog.
- * @enum {string}
- */
-const DialogMode = {
-  DEFAULT: 'default',
-};
-
-
-/**
- * @constructor
- * @extends {PolymerElement}
- * @implements {LoginScreenBehaviorInterface}
- * @implements {MultiStepBehaviorInterface}
- * @implements {OobeI18nBehaviorInterface}
- */
-const UserAllowlistCheckScreenElementBase = mixinBehaviors(
-    [OobeI18nBehavior, LoginScreenBehavior, MultiStepBehavior], PolymerElement);
-
-/**
- * Data that is passed to the screen during onBeforeShow.
- * @typedef {{
- *   enterpriseManaged: boolean,
- *   familyLinkAllowed: boolean,
- * }}
- */
-let UserAllowlistCheckScreenData;
-
-/**
- * @polymer
- */
-class UserAllowlistCheckScreenElement extends
-    UserAllowlistCheckScreenElementBase {
-  static get is() {
-    return 'user-allowlist-check-screen-element';
-  }
-
-  static get template() {
-    return getTemplate();
-  }
-
-  static get properties() {
-    return {
-      /**
-       * @private {string}
-       */
-      allowlistError_: {
-        type: String,
-        value: 'allowlistErrorConsumer',
-      },
-    };
-  }
-
-  get EXTERNAL_API() {
-    return [];
-  }
-
-  defaultUIStep() {
-    return DialogMode.DEFAULT;
-  }
-
-  get UI_STEPS() {
-    return DialogMode;
-  }
-
-  /** @override */
-  ready() {
-    super.ready();
-    this.initializeLoginScreen('UserAllowlistCheckScreen');
-  }
-
-  /**
-   * Event handler that is invoked just before the frame is shown.
-   * @param {UserAllowlistCheckScreenData} opt_data Screen initial payload
-   */
-  onBeforeShow(opt_data) {
-    const isManaged = opt_data && opt_data.enterpriseManaged;
-    const isFamilyLinkAllowed = opt_data && opt_data.familyLinkAllowed;
-    if (isManaged && isFamilyLinkAllowed) {
-      this.allowlistError_ = 'allowlistErrorEnterpriseAndFamilyLink';
-    } else if (isManaged) {
-      this.allowlistError_ = 'allowlistErrorEnterprise';
-    } else {
-      this.allowlistError_ = 'allowlistErrorConsumer';
-    }
-
-    this.$['gaia-allowlist-error'].submitButton.focus();
-  }
-
-  onAllowlistErrorTryAgainClick_() {
-    this.userActed('retry');
-  }
-
-  onAllowlistErrorLinkClick_() {
-    chrome.send('launchHelpApp', [HELP_CANT_ACCESS_ACCOUNT]);
-  }
-}
-
-customElements.define(
-    UserAllowlistCheckScreenElement.is, UserAllowlistCheckScreenElement);
diff --git a/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.ts b/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.ts
new file mode 100644
index 0000000..7725124
--- /dev/null
+++ b/chrome/browser/resources/chromeos/login/screens/common/user_allowlist_check_screen.ts
@@ -0,0 +1,124 @@
+// Copyright 2023 The Chromium Authors
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+/**
+ * @fileoverview Oobe signin screen implementation.
+ */
+
+
+import '../../components/notification_card.js';
+
+import {PolymerElementProperties} from '//resources/polymer/v3_0/polymer/interfaces.js';
+import {mixinBehaviors, PolymerElement} from '//resources/polymer/v3_0/polymer/polymer_bundled.min.js';
+
+import {LoginScreenBehavior, LoginScreenBehaviorInterface} from '../../components/behaviors/login_screen_behavior.js';
+import {MultiStepBehavior, MultiStepBehaviorInterface} from '../../components/behaviors/multi_step_behavior.js';
+import {OobeI18nBehavior, OobeI18nBehaviorInterface} from '../../components/behaviors/oobe_i18n_behavior.js';
+
+import {getTemplate} from './user_allowlist_check_screen.html.js';
+
+// The help topic regarding user not being in the allowlist.
+const HELP_CANT_ACCESS_ACCOUNT = 188036;
+
+/**
+ * UI mode for the dialog.
+ */
+enum DialogMode {
+  DEFAULT = 'default',
+}
+
+const UserAllowlistCheckScreenElementBase =
+    mixinBehaviors(
+        [OobeI18nBehavior, LoginScreenBehavior, MultiStepBehavior],
+        PolymerElement) as {
+      new (): PolymerElement & OobeI18nBehaviorInterface &
+          LoginScreenBehaviorInterface & MultiStepBehaviorInterface,
+    };
+
+/**
+ * Data that is passed to the screen during onBeforeShow.
+ */
+interface UserAllowlistCheckScreenData {
+  enterpriseManaged: boolean;
+  familyLinkAllowed: boolean;
+}
+
+export class UserAllowlistCheckScreenElement extends
+    UserAllowlistCheckScreenElementBase {
+  static get is() {
+    return 'user-allowlist-check-screen-element' as const;
+  }
+
+  static get template(): HTMLTemplateElement {
+    return getTemplate();
+  }
+
+  static get properties(): PolymerElementProperties {
+    return {
+      allowlistError: {
+        type: String,
+        value: 'allowlistErrorConsumer',
+      },
+    };
+  }
+
+  private allowlistError: string;
+
+  override get EXTERNAL_API() {
+    return [];
+  }
+
+  // eslint-disable-next-line @typescript-eslint/naming-convention
+  override defaultUIStep(): DialogMode {
+    return DialogMode.DEFAULT;
+  }
+
+  override get UI_STEPS() {
+    return DialogMode;
+  }
+
+  override ready(): void {
+    super.ready();
+    this.initializeLoginScreen('UserAllowlistCheckScreen');
+  }
+
+  /**
+   * Event handler that is invoked just before the frame is shown.
+   */
+  onBeforeShow(optData: UserAllowlistCheckScreenData): void {
+    const isManaged = optData && optData.enterpriseManaged;
+    const isFamilyLinkAllowed = optData && optData.familyLinkAllowed;
+    if (isManaged && isFamilyLinkAllowed) {
+      this.allowlistError = 'allowlistErrorEnterpriseAndFamilyLink';
+    } else if (isManaged) {
+      this.allowlistError = 'allowlistErrorEnterprise';
+    } else {
+      this.allowlistError = 'allowlistErrorConsumer';
+    }
+
+    const submitButton =
+        this.shadowRoot?.querySelector<HTMLElement>('#submitButton');
+    if (submitButton instanceof HTMLElement) {
+      // TODO(b/320446861): Fix type once GaiaButton can be added.
+      submitButton.focus();
+    }
+  }
+
+  private onAllowlistErrorTryAgainClick(): void {
+    this.userActed('retry');
+  }
+
+  private onAllowlistErrorLinkClick_(): void {
+    chrome.send('launchHelpApp', [HELP_CANT_ACCESS_ACCOUNT]);
+  }
+}
+
+declare global {
+  interface HTMLElementTagNameMap {
+    [UserAllowlistCheckScreenElement.is]: UserAllowlistCheckScreenElement;
+  }
+}
+
+customElements.define(
+    UserAllowlistCheckScreenElement.is, UserAllowlistCheckScreenElement);