Skip to content

Commit

Permalink
fix: interfaces and classes (#409)
Browse files Browse the repository at this point in the history
* fix: check only object types

* docs: generate docs
  • Loading branch information
goodmind authored and gajus committed Jun 10, 2019
1 parent ab62a49 commit c79837b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |};
Expand Down
4 changes: 4 additions & 0 deletions src/rules/requireInexactType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
6 changes: 6 additions & 0 deletions tests/rules/assertions/requireInexactType.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {| |};'
},
Expand Down

0 comments on commit c79837b

Please sign in to comment.