diff --git a/README.md b/README.md index d7d354b6..b00ecc6e 100644 --- a/README.md +++ b/README.md @@ -2203,6 +2203,10 @@ The following patterns are not considered problems: ```js type foo = { foo: string, ... }; +interface Foo { foo: string } + +declare class Foo { foo: string } + type foo = {| |}; type foo = {| bar: string |}; diff --git a/src/rules/requireInexactType.js b/src/rules/requireInexactType.js index 5486bd13..d048afe0 100644 --- a/src/rules/requireInexactType.js +++ b/src/rules/requireInexactType.js @@ -12,6 +12,10 @@ const create = (context) => { ObjectTypeAnnotation (node) { const {inexact, exact} = node; + if (!node.hasOwnProperty('inexact')) { + return; + } + if (always && !inexact && !exact) { context.report({ message: 'Type must be explicit inexact.', diff --git a/tests/rules/assertions/requireInexactType.js b/tests/rules/assertions/requireInexactType.js index 713ece6c..fac73491 100644 --- a/tests/rules/assertions/requireInexactType.js +++ b/tests/rules/assertions/requireInexactType.js @@ -65,6 +65,12 @@ export default { { code: 'type foo = { foo: string, ... };' }, + { + code: 'interface Foo { foo: string }' + }, + { + code: 'declare class Foo { foo: string }' + }, { code: 'type foo = {| |};' },