{"record":{"id":"80935009ba403946","repo":"facebook/flow","slug":"flow-remove-types-includes-and-excludes-must-be-r","errorCode":null,"errorMessage":"flow-remove-types: includes and excludes must be RegExp or path strings. Got: ${pattern}","messagePattern":"flow-remove-types: includes and excludes must be RegExp or path strings\\. Got: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/flow-remove-types/register.js","lineNumber":73,"sourceCode":"// Given a null | string | RegExp | any, returns null | Regexp or throws a\n// more helpful error.\nfunction regexpPattern(pattern) {\n  if (!pattern) {\n    return pattern;\n  }\n  // A very simplified glob transform which allows passing legible strings like\n  // \"myPath/*.js\" instead of a harder to read RegExp like /\\/myPath\\/.*\\.js/.\n  if (typeof pattern === 'string') {\n    pattern = pattern.replace(/\\./g, '\\\\.').replace(/\\*/g, '.*');\n    if (pattern[0] !== '/') {\n      pattern = '/' + pattern;\n    }\n    return new RegExp(pattern);\n  }\n  if (typeof pattern.test === 'function') {\n    return pattern;\n  }\n  throw new Error(\n    'flow-remove-types: ' +\n      'includes and excludes must be RegExp or path strings. Got: ' +\n      pattern,\n  );\n}\n","sourceCodeStart":55,"sourceCodeEnd":79,"githubUrl":"https://github.com/facebook/flow/blob/d1341dac899a79c027762f6b423d896045287620/packages/flow-remove-types/register.js#L55-L79","documentation":"flow-remove-types/register converts each pattern in includes/excludes into a RegExp: strings get '.' escaped and '*' widened to '.*' (and are prefixed with a leading '/'), and anything with a .test function is used as-is. This error is the validation branch for patterns that are neither strings nor RegExp-likes, thrown at startup of the require hook rather than at transform time.","triggerScenarios":"Passing a number, boolean, null, array, or a plain object (e.g. a micromatch or parse-glob result) in the includes or excludes array of require('flow-remove-types/register')({includes: [...]}) or the equivalent CLI flags.","commonSituations":"Config parsed from JSON, YAML, or env vars where a pattern ends up typed as a number or list; passing glob objects from another library; typos like includes: 'src/*.js' where a bare string is iterated char-by-char, producing junk patterns that eventually hit this throw.","solutions":["Make every entry a path string like 'src/*.js' or a RegExp such as new RegExp('/src/.*[.]js$')","Wrap the pattern list in an explicit array so a bare string is not iterated per character","Validate config types at load time (e.g. a zod or joi schema) before handing them to the register hook"],"exampleFix":"// before\nrequire('flow-remove-types/register')({includes: 'lib/*.js'}); // string iterated -> junk entries\n\n// after\nrequire('flow-remove-types/register')({includes: ['lib/*.js']});","handlingStrategy":"type-guard","validationCode":"const isPattern = (p) => typeof p === 'string' || (p != null && typeof p.test === 'function');\nfunction assertPatterns(list) {\n  for (const p of list) {\n    if (!isPattern(p)) throw new TypeError('Pattern must be string or RegExp, got ' + typeof p);\n  }\n}","typeGuard":"const isValidPattern = (p) =>\n  typeof p === 'string' || (p != null && typeof p === 'object' && typeof p.test === 'function');","tryCatchPattern":null,"preventionTips":["Always pass includes/excludes as arrays of strings or RegExps; never a bare string or nested arrays","Validate env- or JSON-sourced config values with a schema before the register hook reads them","Remember string patterns are matched against a leading '/', so write 'src/*.js' rather than a bare glob"],"tags":["config","validation","regexp","flow-remove-types"],"backgroundTag":"invalid-config-value","analyzedSha":"d1341dac899a79c027762f6b423d896045287620","analyzedAt":"2026-08-17T00:07:02.212Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}