Skip to content

Commit 0722187

Browse files
geraintwhitegajus
authored andcommitted
fix: make require-exact-type ignore indexers in map types (#354)
1 parent 65c9225 commit 0722187

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Diff for: src/rules/requireExactType.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const create = (context) => {
1010

1111
return {
1212
TypeAlias (node) {
13-
const {id: {name}, right: {type, exact}} = node;
13+
const {id: {name}, right: {type, exact, indexers}} = node;
1414

1515
if (type === 'ObjectTypeAnnotation') {
16-
if (always && !exact) {
16+
if (always && !exact && indexers.length === 0) {
1717
context.report({
1818
data: {name},
1919
message: 'Type identifier \'{{name}}\' must be exact.',

Diff for: tests/rules/assertions/requireExactType.js

+3
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ export default {
6969
{
7070
code: 'type foo = {| bar: string |};'
7171
},
72+
{
73+
code: 'type foo = { [key: string]: string };'
74+
},
7275
{
7376
code: 'type foo = number;'
7477
},

0 commit comments

Comments
 (0)