diff --git a/packages/eslint-plugin/docs/rules/typedef.mdx b/packages/eslint-plugin/docs/rules/typedef.mdx index 8af5c045244a..827936d63329 100644 --- a/packages/eslint-plugin/docs/rules/typedef.mdx +++ b/packages/eslint-plugin/docs/rules/typedef.mdx @@ -9,6 +9,18 @@ import TabItem from '@theme/TabItem'; > > See **https://typescript-eslint.io/rules/typedef** for documentation. +:::caution + +This is an old, deprecated rule. +It will be removed in a future major version of typescript-eslint. + +Requiring type annotations unnecessarily can be cumbersome to maintain and generally reduces code readability. +TypeScript is often better at inferring types than easily written type annotations would allow. + +**Instead of enabling `typedef`, it is generally recommended to use the `--noImplicitAny` and `--strictPropertyInitialization` compiler options to enforce type annotations only when useful.** + +::: + TypeScript cannot always infer types for all places in code. Some locations require type annotations for their types to be inferred. @@ -30,15 +42,6 @@ class ContainsText { > To enforce type definitions existing on call signatures, use [`explicit-function-return-type`](./explicit-function-return-type.mdx), or [`explicit-module-boundary-types`](./explicit-module-boundary-types.mdx). -:::caution - -Requiring type annotations unnecessarily can be cumbersome to maintain and generally reduces code readability. -TypeScript is often better at inferring types than easily written type annotations would allow. - -**Instead of enabling `typedef`, it is generally recommended to use the `--noImplicitAny` and `--strictPropertyInitialization` compiler options to enforce type annotations only when useful.** - -::: - ## Options For example, with the following configuration: diff --git a/packages/eslint-plugin/src/configs/eslintrc/all.ts b/packages/eslint-plugin/src/configs/eslintrc/all.ts index 3d25e79e33db..2764e4f92a74 100644 --- a/packages/eslint-plugin/src/configs/eslintrc/all.ts +++ b/packages/eslint-plugin/src/configs/eslintrc/all.ts @@ -156,7 +156,6 @@ export = { '@typescript-eslint/strict-boolean-expressions': 'error', '@typescript-eslint/switch-exhaustiveness-check': 'error', '@typescript-eslint/triple-slash-reference': 'error', - '@typescript-eslint/typedef': 'error', '@typescript-eslint/unbound-method': 'error', '@typescript-eslint/unified-signatures': 'error', '@typescript-eslint/use-unknown-in-catch-callback-variable': 'error', diff --git a/packages/eslint-plugin/src/configs/flat/all.ts b/packages/eslint-plugin/src/configs/flat/all.ts index dc40d391e4fd..37f6b8647ddc 100644 --- a/packages/eslint-plugin/src/configs/flat/all.ts +++ b/packages/eslint-plugin/src/configs/flat/all.ts @@ -170,7 +170,6 @@ export default ( '@typescript-eslint/strict-boolean-expressions': 'error', '@typescript-eslint/switch-exhaustiveness-check': 'error', '@typescript-eslint/triple-slash-reference': 'error', - '@typescript-eslint/typedef': 'error', '@typescript-eslint/unbound-method': 'error', '@typescript-eslint/unified-signatures': 'error', '@typescript-eslint/use-unknown-in-catch-callback-variable': 'error', diff --git a/packages/eslint-plugin/src/rules/typedef.ts b/packages/eslint-plugin/src/rules/typedef.ts index c46ec9ff1e76..a952ef44fd24 100644 --- a/packages/eslint-plugin/src/rules/typedef.ts +++ b/packages/eslint-plugin/src/rules/typedef.ts @@ -23,6 +23,10 @@ export default createRule({ name: 'typedef', meta: { type: 'suggestion', + deprecated: { + deprecatedSince: '8.33.0', + message: 'This is an old rule that is no longer recommended for use.', + }, docs: { description: 'Require type annotations in certain places', },