4 ms·
TS by itself is not fully sound which could complicate such a compiler. Example: https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgTwLIEMAOAxArmYUCW4MAvD
by awestroke 4y ago
TS by itself is not fully sound which could complicate such a compiler.
Example: https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgTwLIEMAOAxArmYUCW4MAvDABT5QCmcAXDGFnAEZUBOANDCAG7sBmAGxAB3APz1obfGADmAShIA+GAG8AUDBj5+5SjRgqATDABkp7nzZDRMAISlGgwYo1atbKlCxswlgcIiANyaMAC+oZ7evtrUcAB0UCAAylDScmTyIWEhoJCwUAhoVMAo0KiYOHiEYPQUcfSMLOyKxCpSMrIk8Mjo2LgE4Lng0DCeEFiCsKQA2gCMHEYcAMwAuvFw6GSFxaXlfVWDYFkwAPSnMDtUEMDSaLAQKAgQlwAW+C8fMACCbGxPAB4OnIlFxmFhYJQYCJ8M4YKwYCh4PgAB7cXTA2QvFBgAAmDCYrDYEHUQA https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtgTwLI...
In the example above, the problem is that typescript allows casting function types to omit optional arguments, and also allows using a function with n arguments as a value where a function with >n arguments is expected
- iainmerrick 4y agoYes, those sorts of loopholes would need to be closed. I was imagining a subset of the language, but there might need to be some breaking changes to cover cases like that. Maybe it would end up being so different that it would be an entirely different language? I don't know! But it's hard for me to accept that non-soundness in TS is necessary for TS itself rather than just an unfortunate consequence of the JS language and library that it has to build on top of.