Skip to content

Commit

Permalink
prefer-module: Allow module as TSTypeParameter name (#2213)
Browse files Browse the repository at this point in the history
Co-authored-by: fisker Cheung <[email protected]>
  • Loading branch information
ST-DDT and fisker authored Nov 27, 2023
1 parent b95e75e commit 8f61f7c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions rules/ast/is-reference-identifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/prefer-module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down

0 comments on commit 8f61f7c

Please sign in to comment.