-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to override a property type #1295
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The goal of OverloadOf<>
is to have two almost identical structures where the only difference is the optionality of fields. This allows code generators to produce converters between a type and its overloaded sibling.
Allowing type changes basically prevents generation of these converters and makes this behavior useless.
I may be missing something though, as I haven't spent time on this and the Java client doesn't yet have these converters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm in favor but don't know if there are consequences for strongly typed langs. Deferring to @swallez here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
// but let's address it when it will happen | ||
if (!deepEqual(readProperty.type, property.type)) { | ||
|
||
if (property.type.kind === 'union_of' && property.type.items.some(contains(readProperty.type))) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will this allow arbitrary unions as long as one of its members is the read property, e.g. ReadFoo | Bar
?
Should we rather test that all unwrap
'ed union items are readProperty.type
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This allows the read property to be a single element of the parent union.
Eg:
export class Foo {
bar: string | string[]
}
export class FooRead implements OverloadOf<Foo> {
bar: string[]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah right, I didn't read the relation check in the right direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
As titled.
Related: #1283