angular / clutz

Closure to TypeScript `.d.ts` generator
MIT License
162 stars 60 forks source link

Fix exports of local aliases of the form `exports.B = exports.A`. #912

Closed rkirov closed 5 years ago

rkirov commented 5 years ago

It appears that the emit was previously very broken for this case (syntactically incorrect). This change fixes the emit by detecting rewrites that mention exports.Foo and rewrite them to the corresponding clutz emitted namespace.

Note, that the test .d.ts is still partially incorrect, because we create a type/let pair for just for a let binding. With #896 this will be fully correct.

rkirov commented 5 years ago

On a second thought, a better fix would be to simply not add exports.Foo to the alias map, because closure should resolve those locally. Will try that tomorrow.

rkirov commented 5 years ago

Rewrote this to a much simpler fix. Instead of emitting a self-import, just skip the syntactic alias rewriting step. Turns out the JS compiler output is adequate we were just clobber it previously. PTAL.