Emit Fable erased unions as TS union types #3396
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR stops compiling erased types as
Any
so they can be dealt with in the Fable2XXX step. @ncave @dbrattli Not sure how it affects Rust and Python, although tests are passing. For JS/TS I'm skipping the declaration and for TS I'm transforming the annotations to TS unions/tuples when possible:Fable/src/Fable.Transforms/Fable2Babel.fs
Lines 617 to 638 in 6987bc3
@Booksbaum An unfortunate consequence is this breaks some of the integration tests for anonymous records casted to interfaces because U2, U3... are not compiled as
Any
anymore. For now I just commented out the test because I think it's not a common pattern to have an anonymous record with a field like U2<string, int> (you either have string or int) but we can try to bring them back if needed. I also moved the code to deal with this from FSharp2Fable.Util to Replacements.Util, as it's only use from JS and Python replacements.