Repository: oppia/oppia

Issue:
Remove the AngularJs native variables which are typed as any
After the Angular Migration, the any type in https://github.com/oppia/oppia/blob/develop/core/templates/services/suggestion-modal.service.ts and https://github.com/oppia/oppia/blob/develop/core/templates/domain/utilities/FileDownloadRequestObjectFactory.ts should be removed.




Discussion:

Resolving patch:
diff --git a/core/controllers/creator_dashboard.py b/core/controllers/creator_dashboard.py
--- a/core/controllers/creator_dashboard.py
+++ b/core/controllers/creator_dashboard.py
@@ -45,9 +45,8 @@
 (feedback_models, suggestion_models) = models.Registry.import_models(
     [models.NAMES.feedback, models.NAMES.suggestion])
 
-EXPLORATION_ID_KEY = 'explorationId'
-COLLECTION_ID_KEY = 'collectionId'
-QUESTION_ID_KEY = 'questionId'
+EXPLORATION_ID_KEY = 'exploration_id'
+COLLECTION_ID_KEY = 'collection_id'
 
 
 class OldNotificationsDashboardRedirectPage(base.BaseHandler):
diff --git a/scripts/linters/general_purpose_linter.py b/scripts/linters/general_purpose_linter.py
--- a/scripts/linters/general_purpose_linter.py
+++ b/scripts/linters/general_purpose_linter.py
@@ -232,6 +232,15 @@
             'typings/guppy-defs-b5055b963fdbea5c6c1e92dbf58fdaf3ea0cd8ba.d.ts',
             'core/templates/services/UpgradedServices.ts'),
         'excluded_dirs': ()
+    },
+    {
+        'regexp': re.compile(r'no-explicit-any'),
+        'message': (
+            'Please do not define "any" types. You can refer '
+            'https://github.com/oppia/oppia/wiki/Guide-on-defining-types '
+            'if you\'re having trouble declaring types.'),
+        'excluded_files': (),
+        'excluded_dirs': ()
     }
 ]
 


Test patch:
diff --git a/core/templates/domain/review_test/review-test-backend-api.service.ts b/core/templates/domain/review_test/review-test-backend-api.service.ts
--- a/core/templates/domain/review_test/review-test-backend-api.service.ts
+++ b/core/templates/domain/review_test/review-test-backend-api.service.ts
@@ -47,6 +47,8 @@ export class ReviewTestBackendApiService {
     ).toPromise().then(backendResponse => {
       return this.reviewTestObjectFactory.createFromBackendDict(
         backendResponse);
+    }, errorResponse => {
+      throw new Error(errorResponse.error.error);
     });
   }
 
diff --git a/scripts/linters/general_purpose_linter_test.py b/scripts/linters/general_purpose_linter_test.py
--- a/scripts/linters/general_purpose_linter_test.py
+++ b/scripts/linters/general_purpose_linter_test.py
@@ -74,6 +74,8 @@
     LINTER_TESTS_DIR, 'invalid_throw_with_string.ts')
 INVALID_ESLINT_CAMELCASE_FILEPATH = os.path.join(
     LINTER_TESTS_DIR, 'invalid_eslint_camelcase.ts')
+INVALID_ESLINT_ANY_TYPE_FILEPATH = os.path.join(
+    LINTER_TESTS_DIR, 'invalid_eslint_any_type.ts')
 
 # PY filepaths.
 INVALID_ITERKEY_FILEPATH = os.path.join(LINTER_TESTS_DIR, 'invalid_iterkeys.py')
@@ -334,6 +336,17 @@ def test_invalid_use_of_eslint_camelcase_comment(self):
             'single quotes instead.'], self.linter_stdout)
         self.assert_failed_messages_count(self.linter_stdout, 1)
 
+    def test_invalid_use_of_eslint_no_explicit_any_comment(self):
+        with self.print_swap:
+            general_purpose_linter.GeneralPurposeLinter(
+                [INVALID_ESLINT_ANY_TYPE_FILEPATH], FILE_CACHE, True
+            ).perform_all_lint_checks()
+        self.assert_same_list_elements([
+            'Line 21: Please do not define "any" types. You can refer '
+            'https://github.com/oppia/oppia/wiki/Guide-on-defining-types '
+            'if you\'re having trouble declaring types.'], self.linter_stdout)
+        self.assert_failed_messages_count(self.linter_stdout, 1)
+
 
 class PythonLintTests(test_utils.LinterTestBase):
     """Test the Python lint functions."""
diff --git a/scripts/linters/test_files/invalid_eslint_any_type.ts b/scripts/linters/test_files/invalid_eslint_any_type.ts
new file mode 100644
--- /dev/null
+++ b/scripts/linters/test_files/invalid_eslint_any_type.ts
@@ -0,0 +1,22 @@
+// Copyright 2020 The Oppia Authors. All Rights Reserved.
+//
+// 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.
+
+/**
+ * @fileoverview Invalid syntax .ts file, used by scripts/linters/
+ * js_ts_linter_test.py. eslint @typescript-eslint no explicit any
+ * is not allowed to use.
+ */
+
+// eslint-disable-next-line @typescript-eslint/no-explicit-any
+let a: any;