oxc icon indicating copy to clipboard operation
oxc copied to clipboard

parser: Should parse `@x?.["y"] class C {}`?

Open leaysgur opened this issue 8 months ago • 1 comments

// OK
@x?.y class C1 {}

// NG
@x?.["y"] class C2 {}

https://playground.oxc.rs/#eNpNj0FLxEAMhf9KyXnZVcFLLwpKPQiu6NF6mE7TZWCaKUm6bin976atXTzNhLy8770RPORwOGTH15IeLw/7IfPRiWRP2TiVVJKt3l7W1VcJQwnf/wSwgwT5CNzT/MhA6i6QK/e4gxhIIW9cFBvEpw63jQxtleI2KTuSJnH7J5520DkW5NnSxZh+PlB7pmOvEmosevIakgHX847RtGd8d4wkV0Tq2WMRIpJrDQyKonsVMPc52OJu/yt8xanjE1pqQLm7ub23fkFSdIr1M1ptdjPZIFtQn2o84VLeQFXEz4Xbum4NYpI2UGjCxvOJlFMsrNV8dEaukli+1XCafgElNoyz

Should we parse this as well as TS-ESLint?

https://ast-explorer.dev/#eNo1zLEKAjEQhOFXWaZWDy2vUbCwELSzcS1CSBGJe+E2iCHk3V05bL8Z/oaEEU/3durnmAtWyAal5rDAOmiK8nNvPgx0PbMcPvtNJZ+cKh231DoLi22X07LdGZXx+D929rDAZIHGQsQI/uVuYdY4CWM0SK4ELQyWjv4F9YsvrA==

On the other hand, the TS itself reports errors for both of these cases.

Expression must be enclosed in parentheses to be used as a decorator.

https://www.typescriptlang.org/play/?#code/PTAEHkGkCgAEA8D8A6AnqAxgGwIYGc9QBhARlAG8BfaaEUAOQHE4lkBtAIlQ4F1NcCxAEwVKQA

leaysgur avatar Apr 25 '25 06:04 leaysgur

Maybe, I can try and get it to produce an AST, and then a syntax error "Expression must be enclosed in parentheses to be used as a decorator."

Boshen avatar Apr 25 '25 07:04 Boshen