Skip to content

erasableSyntaxOnly should error on unerasable as/satisfiesΒ #63527

@robpalme

Description

@robpalme

πŸ”Ž 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:

console.log(1 + 1           / 2);

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:

Metadata

Metadata

Assignees

Labels

Needs InvestigationThis issue needs a team member to investigate its status.

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions