deno icon indicating copy to clipboard operation
deno copied to clipboard

Parsing error when `satisfies` follows an Instantiation Expression

Open hen-x opened this issue 1 year ago • 2 comments

Version: Deno 1.40.4

Consider this one-line TS file:

Array<5> satisfies unknown;

As of Typescript 4.9, this is syntactically correct and also type-checks successfully (playground).

However in Deno 1.40.4 (with Typescript 5.3.3), the CLI instead fails with this diagnostic:

error: The module's source code could not be parsed: Expected ';', '}' or <eof> at file:///redacted/type_tests.ts:1:20

  Array<5> satisfies unknown;
                     ~~~~~~~

This appears to persist when an expression like this is used elsewhere (eg wrapped in parens, used on the RHS of an assignment, etc).

I imagine this is getting mis-parsed as the equivalent of (Array < 5 > satisfies) unknown; which would be invalid. That's just speculation however.

❤️

hen-x avatar Feb 10 '24 09:02 hen-x

I opened https://github.com/swc-project/swc/issues/8627

dsherret avatar Feb 10 '24 19:02 dsherret

Thanks @dsherret. For posterity, is it a good idea to take parsing issues directly to swc or are we happy tracking them here as well?

hen-x avatar Feb 10 '24 23:02 hen-x