PassFort / json-schema-to-flow-type

69 stars 17 forks source link

Strict Object Syntax #17

Closed wmonk closed 6 years ago

wmonk commented 6 years ago
wmonk commented 6 years ago

I think we should think about how to represent when schema types don't have additionalProperties set. I think this technically makes a type like:

type Resource = {
   foo: string
} & {
   [key: string]: any
}

Maybe this should be a strict option when parsing the schema.


Although I suppose that's what object types already represent, which is why exact syntax exists 🤔

hirish commented 6 years ago

I don't think the above makes sense:

1) The absence of additionalProperties defaults to True (as you've implemented) 2) Flow object types by default allow additional properties, i.e. they act like the schema definitions. I therefore don't think we need the union. As you say, we just need to special case the additionalProperties: false => exact syntax.