π Search Terms
erasableSyntaxOnly
π Version & Regression Information
- This is the behavior in every version I tried including 6.0.3
β― Playground Link
https://www.typescriptlang.org/play/?erasableSyntaxOnly=true&ts=6.0.3#code/MYewdgziA2CmB00QHMAUBGABAak1ghhJmAK4C2ARrAE6YD0mATAJQDcAUJ50A
π» Code
//@erasableSyntaxOnly:true
console.log(1 + 1 as number / 2);
π Actual behavior
No error - which could lead a naive type-stripping compiler to incorrectly emit:
Though TypeScript itself correctly emits
console.log((1 + 1) / 2);
π Expected behavior
As there is no guaranteed room for (, it should error on this kind of AsExpressions and SatisfiesExpressions
Additional information about the issue
This issue was first discovered by @qnighy and reported as bloomberg/ts-blank-space#62
It was since fixed to emit an error in:
π Search Terms
erasableSyntaxOnly
π Version & Regression Information
β― Playground Link
https://www.typescriptlang.org/play/?erasableSyntaxOnly=true&ts=6.0.3#code/MYewdgziA2CmB00QHMAUBGABAak1ghhJmAK4C2ARrAE6YD0mATAJQDcAUJ50A
π» Code
π Actual behavior
No error - which could lead a naive type-stripping compiler to incorrectly emit:
Though TypeScript itself correctly emits
π Expected behavior
As there is no guaranteed room for
(, it should error on this kind ofAsExpressionsandSatisfiesExpressionsAdditional information about the issue
This issue was first discovered by @qnighy and reported as bloomberg/ts-blank-space#62
It was since fixed to emit an error in: