io-ts-codegen icon indicating copy to clipboard operation
io-ts-codegen copied to clipboard

Generate externs for google closure compiler

Open mk0x9 opened this issue 6 years ago • 5 comments
trafficstars

Google closure compiler mangles all the property names unless you either use bracket syntax to access property (foo['bar'] instead of foo.bar) or specify extern file with external declarations (works similar to ambient declarations in typescript).

Would be extremely nice to be able to generate extern definitions for closure compiler!

mk0x9 avatar Mar 16 '19 13:03 mk0x9

I think I can do it. The only things I yet noted that JSDoc doesn't support intersection types (just enumerate all possible properties and their types) and literal values (just use possible types of that values).

https://github.com/google/closure-compiler/wiki/Types-in-the-Closure-Type-System

mk0x9 avatar Mar 16 '19 15:03 mk0x9

I did basic stuff (https://github.com/mk0x9/io-ts-codegen/commit/f720056209dfe76cae1aa380224dacbfdb392582), but merging type definitions with same properties would take some time later.

mk0x9 avatar Mar 16 '19 19:03 mk0x9

@mk0x9 not sure what's the problem here (I'm not acquainted with GCC) but I think that you can disable renaming https://github.com/google/closure-compiler/pull/2707 is this related?

gcanti avatar Mar 18 '19 09:03 gcanti

It kinda defeats purpose of ADVANCED optimizations. I'll attach examples later, probably at the evening, showing what it is and why I'm doing this.

mk0x9 avatar Mar 18 '19 10:03 mk0x9

Here you can find brief description about GCC's advanced optimizations: https://developers.google.com/closure/compiler/docs/compilation_levels#advanced_optimizations

And here is useful introduction to GCC: https://github.com/roman01la/closure-compiler-handbook

mk0x9 avatar Mar 18 '19 10:03 mk0x9