focus-creative-games / luban

luban是一个强大、易用、优雅、稳定的游戏配置解决方案。luban is a powerful, easy-to-use, elegant and stable game configuration solution.
https://code-philosophy.com/
MIT License
3.32k stars 526 forks source link

[fix] remove empty lines in typescript-json resolve function #148

Closed neko1990 closed 3 months ago

neko1990 commented 3 months ago

当前 typescript-json 的代码中 bean 的 resolve 函数有很多空行,因为每个 field 都会来上一行,无论是否需要resolve。 这个 commit 在生成前判断一下是否为空,不为空再生成对应resolve。可能 scriban 有更优雅的解决方案,但大体搂了一眼没找到。 apply 后 luban_example 中对应的 schema.ts 文件由 5144 行减少到 4853 行。

pirunxi commented 3 months ago

消除空行的必要性不是很高。其他语言生成时也有这个问题,除非你把其他语言的生成代码也一并优化了