Skip to content

Commit

Permalink
fix: make require-exact-type ignore indexers in map types (#354)
Browse files Browse the repository at this point in the history
  • Loading branch information
geraintwhite authored and gajus committed Sep 18, 2018
1 parent 65c9225 commit 0722187
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/rules/requireExactType.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ const create = (context) => {

return {
TypeAlias (node) {
const {id: {name}, right: {type, exact}} = node;
const {id: {name}, right: {type, exact, indexers}} = node;

if (type === 'ObjectTypeAnnotation') {
if (always && !exact) {
if (always && !exact && indexers.length === 0) {
context.report({
data: {name},
message: 'Type identifier \'{{name}}\' must be exact.',
Expand Down
3 changes: 3 additions & 0 deletions tests/rules/assertions/requireExactType.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ export default {
{
code: 'type foo = {| bar: string |};'
},
{
code: 'type foo = { [key: string]: string };'
},
{
code: 'type foo = number;'
},
Expand Down

0 comments on commit 0722187

Please sign in to comment.