Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Sometimes it's super easy to encounter incompleteness in the compiler...
Of course here you can just refactor this into
layers.map(layer => layer)as it doesn't do anything but that's not always the case.So how would tell the compiler that it's safe to compile this? I would just go with an assertion somewhere but there's also a stupid way to solve it...
Ha! Stupid as it may be but it does unlock an insight... what if there was a way to tell the compiler to do this same thing without having to write all those cases... maybe something like the following?
And that's the exact thing this experiment implements.
It also solves incompleteness like the following...
distribute (x) { y }is an erasable syntax that compiles to{ y }. And the compiler checksyfor each member of type ofx. I know that sounds like a nightmare ifxis a big union or ifyhas many nodes. But we can always put limit to those things. And at the end this is just an experiment to have fun!Fixes microsoft/TypeScript#25051 (that's the main inspiration for this PR cc @jcalz)
Fixes microsoft/TypeScript#30581 (that's already "fixed" but not all cases are fixed and
distributehas nicer DX as there's no ceremony needed)Probably fixes a ton of issues that I'm not aware of. Because it enables you to overcome the most basic incompleteness that @RyanCavanaugh talks about here
Let me know what y'all think and as always feel free to close this PR if y'all think this won't take off. Thanks for reading!