{"record":{"id":"6eb6ff33e3c0b09a","repo":"tailwindlabs/tailwindcss","slug":"css-escape-requires-an-argument","errorCode":null,"errorMessage":"`CSS.escape` requires an argument.","messagePattern":"`CSS\\.escape` requires an argument\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"packages/tailwindcss/src/utils/escape.ts","lineNumber":4,"sourceCode":"// https://drafts.csswg.org/cssom/#serialize-an-identifier\nexport function escape(value: string) {\n  if (arguments.length === 0) {\n    throw new TypeError('`CSS.escape` requires an argument.')\n  }\n  let string = String(value)\n  let length = string.length\n  let index = -1\n  let codeUnit: number\n  let result = ''\n  let firstCodeUnit = string.charCodeAt(0)\n\n  if (\n    // If the character is the first character and is a `-` (U+002D), and\n    // there is no second character, […]\n    length === 1 &&\n    firstCodeUnit === 0x002d\n  ) {\n    return '\\\\' + string\n  }\n\n  while (++index < length) {","sourceCodeStart":1,"sourceCodeEnd":22,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/tailwindcss/src/utils/escape.ts#L1-L22","documentation":"Thrown by escape() in escape.ts to mirror the native CSS.escape() Web API, which requires exactly one argument. The check uses arguments.length === 0 so it fires only when the function is called with no arguments at all — not when undefined is passed (undefined gets coerced to the string 'undefined'). It is a TypeError, not a generic Error, matching the spec.","triggerScenarios":"Calling escape() with no arguments: escape(). Calling it via apply/call with an empty array. Destructuring or spreading that accidentally drops the argument.","commonSituations":"Refactoring a call site and dropping the argument. Using .map(escape) on an array that contains holes or is unexpectedly empty in a way that bypasses the argument (note: .map(escape) actually passes the element, so this is safe; the real trigger is a bare escape()).","solutions":["Pass the identifier string: escape('my-class').","If the value may be absent, guard the call: value !== undefined && escape(value).","Prefer TypeScript to catch missing-argument calls at compile time (the signature is escape(value: string))."],"exampleFix":"// before — throws at runtime\nlet id = escape()\n\n// after\nlet id = escape('my-class')","handlingStrategy":"type-guard","validationCode":"if (arguments.length === 0 || value === undefined) {\n  throw new TypeError('escape requires a value')\n}\nescape(value)","typeGuard":"function isEscapable(value: unknown): value is string {\n  return typeof value === 'string'\n}","tryCatchPattern":null,"preventionTips":["Rely on TypeScript's type system to prevent zero-argument calls.","Audit call sites when refactoring to ensure the argument survives.","Avoid apply/call patterns that can drop the argument."],"tags":["tailwindcss","css-escape","api-compat","typescript"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}