Browse Source

ref: set noImplicitAny compiler setting to true (#83366)

requires https://github.com/getsentry/getsentry/pull/16121

refs https://github.com/getsentry/frontend-tsc/issues/79

This PR turns on the `noImplicitAny` compiler setting for the `sentry`
repository.
Dominik Dorfmeister 1 month ago
parent
commit
349f28bcf5

+ 2 - 2
api-docs/index.ts

@@ -78,8 +78,8 @@ function build(originalFile, _, bundleTo) {
   );
 }
 
-let originalFile;
-let targetDirValue;
+let originalFile: any;
+let targetDirValue: any;
 
 const argv = process.argv.slice(2);
 

+ 1 - 1
config/tsconfig.base.json

@@ -35,7 +35,7 @@
     // Type checking specific options
     "alwaysStrict": false,
     "noFallthroughCasesInSwitch": true,
-    "noImplicitAny": false,
+    "noImplicitAny": true,
     "noImplicitReturns": true,
     "noImplicitThis": true,
     "noUnusedLocals": true,

+ 4 - 0
eslint.config.mjs

@@ -12,14 +12,18 @@
 import * as emotion from '@emotion/eslint-plugin';
 import eslint from '@eslint/js';
 import prettier from 'eslint-config-prettier';
+// @ts-expect-error TS(7016): Could not find a declaration file
 import importPlugin from 'eslint-plugin-import';
 import jest from 'eslint-plugin-jest';
 import jestDom from 'eslint-plugin-jest-dom';
 import react from 'eslint-plugin-react';
+// @ts-expect-error TS(7016): Could not find a declaration file
 import reactHooks from 'eslint-plugin-react-hooks';
+// @ts-expect-error TS(7016): Could not find a declaration file
 import sentry from 'eslint-plugin-sentry';
 import simpleImportSort from 'eslint-plugin-simple-import-sort';
 import testingLibrary from 'eslint-plugin-testing-library';
+// @ts-expect-error TS (7016): Could not find a declaration file
 import typescriptSortKeys from 'eslint-plugin-typescript-sort-keys';
 import globals from 'globals';
 import invariant from 'invariant';

+ 1 - 0
package.json

@@ -188,6 +188,7 @@
     "@testing-library/jest-dom": "6.4.5",
     "@testing-library/react": "16.0.0",
     "@testing-library/user-event": "14.5.2",
+    "@types/eslint-config-prettier": "^6.11.3",
     "@types/node": "^22.9.1",
     "babel-gettext-extractor": "^4.1.3",
     "babel-jest": "29.7.0",

+ 1 - 2
static/app/__mocks__/api.tsx

@@ -196,8 +196,7 @@ class Client implements ApiNamespace.Client {
     const asyncDelay = Client.asyncDelay;
 
     return (...args: T) => {
-      // @ts-expect-error
-      if (RealApi.hasProjectBeenRenamed(...args)) {
+      if ((RealApi.hasProjectBeenRenamed as any)(...args)) {
         return;
       }
       respond(asyncDelay, func, ...args);

+ 4 - 4
static/app/actionCreators/formSearch.tsx

@@ -30,9 +30,9 @@ const createSearchMap = ({
   return listOfFields.map<FormSearchField>(field => ({
     ...other,
     route,
-    title: typeof field !== 'function' ? (field.label as string) : undefined,
-    description: typeof field !== 'function' ? (field.help as string) : undefined,
-    field,
+    title: typeof field !== 'function' ? (field?.label as string) : undefined,
+    description: typeof field !== 'function' ? (field?.help as string) : undefined,
+    field: field!,
   }));
 };
 
@@ -42,7 +42,7 @@ export function loadSearchMap() {
   const context = require.context('../data/forms', true, /\.tsx?$/);
 
   // Get a list of all form fields defined in `../data/forms`
-  const allFormFields: FormSearchField[] = context.keys().flatMap(key => {
+  const allFormFields: FormSearchField[] = context.keys().flatMap((key: any) => {
     const mod = context(key);
 
     // Since we're dynamically importing an entire directly, there could be malformed modules defined?

+ 6 - 2
static/app/actionCreators/group.tsx

@@ -256,8 +256,12 @@ export function paramsToQueryArgs(params: ParamsType): QueryArgs {
   // only include date filters if they are not null/undefined
   if (params.query) {
     ['start', 'end', 'period', 'utc'].forEach(prop => {
-      if (params[prop] !== null && params[prop] !== undefined) {
-        p[prop === 'period' ? 'statsPeriod' : prop] = params[prop];
+      if (
+        params[prop as keyof typeof params] !== null &&
+        params[prop as keyof typeof params] !== undefined
+      ) {
+        (p as any)[prop === 'period' ? 'statsPeriod' : prop] =
+          params[prop as keyof typeof params];
       }
     });
   }

+ 3 - 6
static/app/actionCreators/indicator.tsx

@@ -51,12 +51,9 @@ export function addMessage(
 
   // XXX: Debug for https://sentry.io/organizations/sentry/issues/1595204979/
   if (
-    // @ts-expect-error
-    typeof msg?.message !== 'undefined' &&
-    // @ts-expect-error
-    typeof msg?.code !== 'undefined' &&
-    // @ts-expect-error
-    typeof msg?.extra !== 'undefined'
+    typeof (msg as any)?.message !== 'undefined' &&
+    typeof (msg as any)?.code !== 'undefined' &&
+    typeof (msg as any)?.extra !== 'undefined'
   ) {
     Sentry.captureException(new Error('Attempt to XHR response to Indicators'));
   }

+ 3 - 1
static/app/actionCreators/monitors.tsx

@@ -70,7 +70,9 @@ export async function updateMonitor(
     // If we are updating a single value in the monitor we can read the
     // validation error for that key, otherwise fallback to the default error
     const validationError =
-      updateKeys.length === 1 ? respError.responseJSON?.[updateKeys[0]!]?.[0] : undefined;
+      updateKeys.length === 1
+        ? (respError.responseJSON?.[updateKeys[0]!] as any)?.[0]
+        : undefined;
 
     logException(err);
     addErrorMessage(validationError ?? t('Unable to update monitor.'));

+ 2 - 2
static/app/actionCreators/prompts.tsx

@@ -290,12 +290,12 @@ export async function batchedPromptsCheck<T extends readonly string[]>(
   for (const featureName of features) {
     const item = responseFeatures[featureName];
     if (item) {
-      result[featureName] = {
+      (result as any)[featureName] = {
         dismissedTime: item.dismissed_ts,
         snoozedTime: item.snoozed_ts,
       };
     } else {
-      result[featureName] = null;
+      (result as any)[featureName] = null;
     }
   }
   return result as {[key in T[number]]: PromptData};

Some files were not shown because too many files changed in this diff