Closed AloeareV closed 4 years ago
Hi, and thanks for the issue and PR.
I'm actually wondering if this makes more sense as the default behaviour than the current one, if it is not too much of a breaking change (I'll have to think a bit about that part). However, if I was to make this change it should probably be the same for all output languages, and be on the code generation level. Fortunately, Rust, Kotlin and TypeScript all support type aliases, so it should be OK to make this change for all of them.
By the way, out of curiosity, which interface are you using? Type provider, CLI, WASM or web?
I'm using the type provider. I'm making a whole bunch of rpc calls, writing down the responses I get, and pointing json_typegen at them so I can have concrete types instead of needing to do a bunch of runtime json parsing.
I don't think it would be a breaking change, I think the only thing it would change is behavior that's currently a panic. Looks like Kotlan says typealias
instead of type
so I'll need to at least add a check for that to not just turn a panic into a worse panic.
I'm using the type provider. I'm making a whole bunch of rpc calls, writing down the responses I get, and pointing json_typegen at them so I can have concrete types instead of needing to do a bunch of runtime json parsing.
Which means we can do compile time analyses to confirm correctness! Though... we might have run into an interesting case in spite of this.
Sorry. This took a bit longer than expected. Ended up coming to the conclusion that this should be the default, and that there would not be much point in adding an option to turn it off. There also turned out to be a few details that made it so I couldn't really use your code directly either, so ended up doing it as a new commit (51c69128f) and added you as a co-author to that one (as your code was the starting point for it).
Anyway, thanks again for the issue and the PR. I'll make a release after a couple of other small changes.
One thing I have realized might be an issue for you, based on how you describe your use though: If the type is a list, the requested type name will be used for the elements of the list, rather than the list itself.
This is functionality that I need locally, and perhaps it would be useful for others. I'm happy to refactor if needed, I'm not familiar enough with the package to know where the best place to put the new code is. Fixes #19