Skip redundant modifiers#1241
Conversation
|
Thanks for taking the time to put this together @michaelnisi! The PR is greatly appreciated. I'm going to hand this off to @designatednerd for review since she's our new mobile architect 😄 |
designatednerd
left a comment
There was a problem hiding this comment.
I'm crap at typescript so I'll have to defer to an actual ts developer on that bit.
| ); | ||
|
|
||
| expect(generator.output).toBe(stripIndent` | ||
| struct Hero: GraphQLFragment { |
There was a problem hiding this comment.
I haven't been able to dig super-deep into what's happening here, but is the adoptedProtocols thing what shoves this into an extension rather than just into the big namespaced enum?
There was a problem hiding this comment.
Give me a minute to refresh my memory.
There was a problem hiding this comment.
First thing tomorrow morning.
There was a problem hiding this comment.
No, these changes simply skip the public modifier if we are in a namespace, see below. 👇 adoptedProtocols is checked to see if our struct is a fragment.
There was a problem hiding this comment.
Nope lost the changes in my flood of email 😄 will take another look
|
Rebased and reviewed. These changes simply make the previously static The goal is to skip the For classes: const isRedundant = !!namespace;
const modifiers = isRedundant ? ["final"] : ["public", "final"];For structs: const isRedundant = adoptedProtocols.includes("GraphQLFragment") && !!namespace;
const modifier = isRedundant ? "" : "public ";These changes cover queries and fragments. |
|
@trevor-scheer I'll leave this to you to review the typescript on Monday but the swift stuff is ready to ship! |
trevor-scheer
left a comment
There was a problem hiding this comment.
Minor nitpick but TS changes LGTM!
|
Rebased and ready to go. However, there’s a new (unrelated?) failing CI check for Node.js 10: Let me know if this is a new requirement the Swift generator is neglecting and if I can help. |
|
@michaelnisi those are some flaky tests that we've been tolerating for quite some time now. All was well after a re-run. Thanks for the contribution! 🎉 |
|
This should only apply if the classes and structs are defined within an extension, which I think is equivalent to public enum MyNameSpace {
struct Hero: GraphQLFragment {
public var name: String
public var age: Int
}
}and the struct is internal. |
Resolves #1177. The goal is to prevent compiler warnings for redundant access-level modifiers when using
--namespace.It covers queries and fragments, according to basic testing at least, resolving the initial issue. Are there more types affected by this? @martijnwalraven