Skip to content

Commit c79837b

Browse files
goodmindgajus
authored andcommitted
fix: interfaces and classes (#409)
* fix: check only object types * docs: generate docs
1 parent ab62a49 commit c79837b

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,6 +2203,10 @@ The following patterns are not considered problems:
22032203
```js
22042204
type foo = { foo: string, ... };
22052205

2206+
interface Foo { foo: string }
2207+
2208+
declare class Foo { foo: string }
2209+
22062210
type foo = {| |};
22072211

22082212
type foo = {| bar: string |};

src/rules/requireInexactType.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ const create = (context) => {
1212
ObjectTypeAnnotation (node) {
1313
const {inexact, exact} = node;
1414

15+
if (!node.hasOwnProperty('inexact')) {
16+
return;
17+
}
18+
1519
if (always && !inexact && !exact) {
1620
context.report({
1721
message: 'Type must be explicit inexact.',

tests/rules/assertions/requireInexactType.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,12 @@ export default {
6565
{
6666
code: 'type foo = { foo: string, ... };'
6767
},
68+
{
69+
code: 'interface Foo { foo: string }'
70+
},
71+
{
72+
code: 'declare class Foo { foo: string }'
73+
},
6874
{
6975
code: 'type foo = {| |};'
7076
},

0 commit comments

Comments
 (0)