Kampfkarren / full-moon

A lossless Lua 5.1 parser
Mozilla Public License 2.0
377 stars 48 forks source link

Unable to parse intersection with `typeof` (rc5) #314

Open jeparlefrancais opened 1 month ago

jeparlefrancais commented 1 month ago

I found this issue with full-moon rc5, where intersection types using typeof don't parse:

export type Expect = typeof({}) & string

Which comes up in jest for example: https://github.com/jsdotlua/jest-lua/blob/main/src/expect/src/types.lua#L406-L408

YetAnotherClown commented 2 weeks ago

It looks like the minimal repro provided is actually incorrect, it does parse. The issue appears in the Jest example, specifically having typeof() on a newline.

A proper minimal repro would be:

type T =
    typeof({})