{"record":{"id":"dab8326e62380fd7","repo":"evanw/esbuild","slug":"unexpected-dab832","errorCode":null,"errorMessage":"Unexpected \"...\"","messagePattern":"Unexpected \"\\.\\.\\.\"","errorType":"panic","errorClass":"LexerPanic","httpStatus":null,"severity":"error","filePath":"internal/js_parser/js_parser.go","lineNumber":3350,"sourceCode":"\t}\n\n\t// Are these arguments for a call to a function named \"async\"?\n\tif isAsync {\n\t\tp.logExprErrors(&errors)\n\t\tasync := js_ast.Expr{Loc: loc, Data: &js_ast.EIdentifier{\n\t\t\tRef: p.storeNameInRef(js_lexer.MaybeSubstring{String: \"async\"})}}\n\t\treturn js_ast.Expr{Loc: loc, Data: &js_ast.ECall{\n\t\t\tTarget: async,\n\t\t\tArgs:   items,\n\t\t}}\n\t}\n\n\t// Is this a chain of expressions and comma operators?\n\tif len(items) > 0 {\n\t\tp.logExprErrors(&errors)\n\t\tif spreadRange.Len > 0 {\n\t\t\tp.log.AddError(&p.tracker, spreadRange, \"Unexpected \\\"...\\\"\")\n\t\t\tpanic(js_lexer.LexerPanic{})\n\t\t}\n\t\tvalue := js_ast.JoinAllWithComma(items)\n\t\tp.markExprAsParenthesized(value, loc, isAsync)\n\t\treturn value\n\t}\n\n\t// Indicate that we expected an arrow function\n\tp.lexer.Expected(js_lexer.TEqualsGreaterThan)\n\treturn js_ast.Expr{}\n}\n\ntype invalidLog struct {\n\tinvalidTokens  []logger.Range\n\tsyntaxFeatures []syntaxFeature\n}\n\ntype syntaxFeature struct {\n\tfeature compat.JSFeature","sourceCodeStart":3332,"sourceCodeEnd":3368,"githubUrl":"https://github.com/evanw/esbuild/blob/f6058f8364fe7ab91ca57a83e02577ed74c9cae4/internal/js_parser/js_parser.go#L3332-L3368","documentation":"In a parenthesized expression that esbuild concluded is not an arrow function, a spread '...' was present (spreadRange non-empty). Spread is only valid in arrow arguments, calls, or array literals, so as a bare parenthesized element it is illegal.","triggerScenarios":"'(...args)' or '(...a)' used as a standalone parenthesized expression without a following '=>'.","commonSituations":"Forgot the '=>'; copy-pasting a function signature; partial refactor that dropped the arrow body.","solutions":["Add '=> body' to turn it into an arrow function.","Remove the '...' if spread was not intended as a parameter.","Move the spread into a call/array context where it is legal."],"exampleFix":"// before\nconst f = (...a)\n// after\nconst f = (...a) => a","handlingStrategy":"validation","validationCode":"import \"github.com/evanw/esbuild/pkg/api\"\nres := api.Transform(src, api.TransformOptions{Loader: api.LoaderJS})\nfor _, m := range res.Errors {\n  if strings.Contains(m.Text, \"Unexpected \\\"...\\\"\") {\n    // spread used outside an arrow/call/array context\n  }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Ensure every '(...args)' parameter list is followed by '=> body'.","Lint with eslint/tsc to catch spread outside legal contexts.","Review refactors that removed an arrow body."],"tags":["syntax-error","parser","spread","arrow-function"],"backgroundTag":null,"analyzedSha":"f6058f8364fe7ab91ca57a83e02577ed74c9cae4","analyzedAt":"2026-08-09T18:37:22.223Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}