Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix: require-exact-type must not add exact types for explicitly inexa…
…ct types (fixes #444)
  • Loading branch information
gajus committed May 15, 2020
1 parent 0b68853 commit 4238464
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/rules/requireExactType.js
Expand Up @@ -15,9 +15,13 @@ const create = (context) => {

return {
ObjectTypeAnnotation (node) {
const {exact, indexers} = node;
const {
exact,
indexers,
inexact,
} = node;

if (node.parent.type !== 'InterfaceDeclaration' && always && !exact && indexers.length === 0) {
if (node.parent.type !== 'InterfaceDeclaration' && always && !exact && !inexact && indexers.length === 0) {
context.report({
fix: (fixer) => {
return [
Expand Down
8 changes: 6 additions & 2 deletions tests/rules/assertions/requireExactType.js
@@ -1,7 +1,6 @@
export default {
invalid: [
// Always

{
code: 'type foo = {};',
errors: [
Expand Down Expand Up @@ -137,7 +136,6 @@ export default {
valid: [

// Always

{
code: 'type foo = {| |};',
},
Expand Down Expand Up @@ -225,5 +223,11 @@ export default {
function?: {| name: string |};
}`,
},

// Explicit inexact

{
code: 'type A = { a: string, ... }',
},
],
};

0 comments on commit 4238464

Please sign in to comment.