From 8f61f7ce286879af97e095c05f6ed538e00f1593 Mon Sep 17 00:00:00 2001 From: ST-DDT Date: Mon, 27 Nov 2023 17:48:26 +0100 Subject: [PATCH] `prefer-module`: Allow `module` as TSTypeParameter name (#2213) Co-authored-by: fisker Cheung --- rules/ast/is-reference-identifier.js | 5 +++++ test/prefer-module.mjs | 1 + 2 files changed, 6 insertions(+) diff --git a/rules/ast/is-reference-identifier.js b/rules/ast/is-reference-identifier.js index cbe411e62f..7ebf894119 100644 --- a/rules/ast/is-reference-identifier.js +++ b/rules/ast/is-reference-identifier.js @@ -120,6 +120,11 @@ function isNotReference(node) { return parent.parameters.includes(node); } + // `type Foo = { [Identifier in keyof string]: number; };` + case 'TSTypeParameter': { + return parent.name === node; + } + // `type Identifier = Foo` case 'TSTypeAliasDeclaration': { return parent.id === node; diff --git a/test/prefer-module.mjs b/test/prefer-module.mjs index f2f9e073e2..81b7836fff 100644 --- a/test/prefer-module.mjs +++ b/test/prefer-module.mjs @@ -272,6 +272,7 @@ test.typescript({ 'type ModuleRegistry = { [module: string]: string };', 'const module = 1; type ModuleRegistry = { [module: string]: string };', 'type module = number[]; type ModuleRegistry = { [module: string]: string };', + 'type Data = { [module in keyof string]: number; };', 'type ModuleRegistry = { [exports: string]: string };', ], invalid: [],