RepoPilot

What types does the function expect and return?

About sindresorhus/escape-string-regexp · 2 messages · last activity 7/13/2026

Question

What types does the function expect and return?

RepoPilot

According to the TypeScript definitions in [index.d.ts:L16-L17], the escapeStringRegexp function has this signature:

export default function escapeStringRegexp(string: string): string;

Expected type: The function expects a string parameter.

Return type: The function returns a string.

The implementation in [index.js:L1-L4] enforces this by checking the input type and throwing a TypeError if the argument is not a string:

if (typeof string !== 'string') {
    throw new TypeError('Expected a string');
}

FOLLOW_UPS:

  • What characters does the function escape?
  • Can the function handle Unicode characters like emoji?
  • What is the actual escape implementation?

Public Q&A. Generated by RepoPilot from the actual source of sindresorhus/escape-string-regexp. AI answers can be incomplete or stale — verify before relying on them.