Skip to content

Commit 387eeb5

Browse files
docs(eslint-plugin): [typedef] deprecate the rule (#11202)
docs(eslint-plugin) [typedef] deprecate the rule
1 parent f9e0eb9 commit 387eeb5

File tree

4 files changed

+16
-11
lines changed

4 files changed

+16
-11
lines changed

‎packages/eslint-plugin/docs/rules/typedef.mdx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,18 @@ import TabItem from '@theme/TabItem';
99
>
1010
> See **https://typescript-eslint.io/rules/typedef** for documentation.
1111
12+
:::caution
13+
14+
This is an old, deprecated rule.
15+
It will be removed in a future major version of typescript-eslint.
16+
17+
Requiring type annotations unnecessarily can be cumbersome to maintain and generally reduces code readability.
18+
TypeScript is often better at inferring types than easily written type annotations would allow.
19+
20+
**Instead of enabling `typedef`, it is generally recommended to use the `--noImplicitAny` and `--strictPropertyInitialization` compiler options to enforce type annotations only when useful.**
21+
22+
:::
23+
1224
TypeScript cannot always infer types for all places in code.
1325
Some locations require type annotations for their types to be inferred.
1426

@@ -30,15 +42,6 @@ class ContainsText {
3042

3143
> 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).
3244
33-
:::caution
34-
35-
Requiring type annotations unnecessarily can be cumbersome to maintain and generally reduces code readability.
36-
TypeScript is often better at inferring types than easily written type annotations would allow.
37-
38-
**Instead of enabling `typedef`, it is generally recommended to use the `--noImplicitAny` and `--strictPropertyInitialization` compiler options to enforce type annotations only when useful.**
39-
40-
:::
41-
4245
## Options
4346

4447
For example, with the following configuration:

‎packages/eslint-plugin/src/configs/eslintrc/all.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ export = {
156156
'@typescript-eslint/strict-boolean-expressions': 'error',
157157
'@typescript-eslint/switch-exhaustiveness-check': 'error',
158158
'@typescript-eslint/triple-slash-reference': 'error',
159-
'@typescript-eslint/typedef': 'error',
160159
'@typescript-eslint/unbound-method': 'error',
161160
'@typescript-eslint/unified-signatures': 'error',
162161
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',

‎packages/eslint-plugin/src/configs/flat/all.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,6 @@ export default (
170170
'@typescript-eslint/strict-boolean-expressions': 'error',
171171
'@typescript-eslint/switch-exhaustiveness-check': 'error',
172172
'@typescript-eslint/triple-slash-reference': 'error',
173-
'@typescript-eslint/typedef': 'error',
174173
'@typescript-eslint/unbound-method': 'error',
175174
'@typescript-eslint/unified-signatures': 'error',
176175
'@typescript-eslint/use-unknown-in-catch-callback-variable': 'error',

‎packages/eslint-plugin/src/rules/typedef.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export default createRule<Options, MessageIds>({
2323
name: 'typedef',
2424
meta: {
2525
type: 'suggestion',
26+
deprecated: {
27+
deprecatedSince: '8.33.0',
28+
message: 'This is an old rule that is no longer recommended for use.',
29+
},
2630
docs: {
2731
description: 'Require type annotations in certain places',
2832
},

0 commit comments

Comments
 (0)