Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prefer-module: allow module as TSTypeParameter name #2213

Merged
merged 3 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 Data = { [module 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