DEV: Add safe deprecation to `Discourse.User`

DEV: Add safe deprecation to Discourse.User

diff --git a/app/assets/javascripts/discourse/app/models/user.js b/app/assets/javascripts/discourse/app/models/user.js
index fc98218..f5435ae 100644
--- a/app/assets/javascripts/discourse/app/models/user.js
+++ b/app/assets/javascripts/discourse/app/models/user.js
@@ -990,18 +990,20 @@ User.reopenClass(Singleton, {
   }
 });
 
-let warned = false;
-Object.defineProperty(Discourse, "User", {
-  get() {
-    if (!warned) {
-      deprecated("Import the User class instead of using User", {
-        since: "2.4.0",
-        dropFrom: "2.6.0"
-      });
-      warned = true;
+if (typeof Discourse !== "undefined") {
+  let warned = false;
+  Object.defineProperty(Discourse, "User", {
+    get() {
+      if (!warned) {
+        deprecated("Import the User class instead of using User", {
+          since: "2.4.0",
+          dropFrom: "2.6.0"
+        });
+        warned = true;
+      }
+      return User;
     }
-    return User;
-  }
-});
+  });
+}
 
 export default User;

GitHub sha: b4bd238d