You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(eslint-plugin): [consistent-type-imports] ignore files with decorators, experimentalDecorators, and emitDecoratorMetadata (typescript-eslint#8335)
Copy file name to clipboardExpand all lines: docs/packages/Parser.mdx
+7Lines changed: 7 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,7 @@ interface ParserOptions {
40
40
};
41
41
ecmaVersion?:number|'latest';
42
42
emitDecoratorMetadata?:boolean;
43
+
experimentalDecorators?:boolean;
43
44
extraFileExtensions?:string[];
44
45
jsDocParsingMode?:'all'|'none'|'type-info';
45
46
jsxFragmentName?:string|null;
@@ -128,6 +129,12 @@ Specifies the version of ECMAScript syntax you want to use. This is used by the
128
129
129
130
This option allow you to tell parser to act as if `emitDecoratorMetadata: true` is set in `tsconfig.json`, but without [type-aware linting](../getting-started/Typed_Linting.mdx). In other words, you don't have to specify `parserOptions.project` in this case, making the linting process faster.
130
131
132
+
### `experimentalDecorators`
133
+
134
+
> Default `undefined`.
135
+
136
+
This option allow you to tell parser to act as if `experimentalDecorators: true` is set in `tsconfig.json`, but without [type-aware linting](../getting-started/Typed_Linting.mdx). In other words, you don't have to specify `parserOptions.project` in this case, making the linting process faster.
The `emitDecoratorMetadata` compiler option changes the code the TypeScript emits. In short - it causes TypeScript to create references to value imports when they are used in a type-only location. If you are using `emitDecoratorMetadata` then our tooling will require additional information in order for the rule to work correctly.
98
+
:::note
99
+
If you are using `experimentalDecorators: false` (eg [TypeScript v5.0's stable decorators](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-5-0.html#decorators)) then the rule will always report errors as expected.
100
+
This caveat **only** applies to `experimentalDecorators: true`
101
+
:::
99
102
100
-
If you are using [type-aware linting](/getting-started/typed-linting), then you just need to ensure that the `tsconfig.json` you've configured for `parserOptions.project` has `emitDecoratorMetadata` turned on. Otherwise you can explicitly tell our tooling to analyze your code as if the compiler option was turned on [by setting `parserOptions.emitDecoratorMetadata` to `true`](https://github.com/typescript-eslint/typescript-eslint/blob/main/packages/parser/README.md#parseroptionsemitdecoratormetadata).
103
+
The rule will **_not_** report any errors in files _that contain decorators_ when **both**`experimentalDecorators` and `emitDecoratorMetadata` are turned on.
104
+
105
+
> See [Blog > Changes to consistent-type-imports when used with legacy decorators and decorator metadata](/blog/changes-to-consistent-type-imports-with-decorators) for more details.
106
+
107
+
If you are using [type-aware linting](https://typescript-eslint.io/linting/typed-linting) then we will automatically infer your setup from your tsconfig and you should not need to configure anything.
108
+
Otherwise you can explicitly tell our tooling to analyze your code as if the compiler option was turned on by setting both [`parserOptions.emitDecoratorMetadata = true`](https://typescript-eslint.io/packages/parser/#emitdecoratormetadata) and [`parserOptions.experimentalDecorators = true`](https://typescript-eslint.io/packages/parser/#experimentaldecorators).
109
+
110
+
## Comparison with `importsNotUsedAsValues` / `verbatimModuleSyntax`
111
+
112
+
[`verbatimModuleSyntax`](https://www.typescriptlang.org/tsconfig#verbatimModuleSyntax) was introduced in TypeScript v5.0 (as a replacement for `importsNotUsedAsValues`).
113
+
This rule and `verbatimModuleSyntax`_mostly_ behave in the same way.
0 commit comments