{"record":{"id":"1e8e9eef38d0906b","repo":"facebook/flow","slug":"flow-remove-types-the-checkpragma-option-has-be","errorCode":null,"errorMessage":"flow-remove-types: the \"checkPragma\" option has been replaced by \"all\".","messagePattern":"flow-remove-types: the \"checkPragma\" option has been replaced by \"all\"\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/flow-remove-types/index.js","lineNumber":47,"sourceCode":" *     COMPLIANT! Instead, use `declare foo: string;` for type-only fields.\n *\n *   - removeEmptyImports: (default: false)\n *     If true, removes empty import statements that remain after removing\n *     all type and typeof imports (e.g. `import {} from 'some-module'`).\n *\n * Returns an object with two methods:\n *\n *   - .toString()\n *     Returns the transformed source code.\n *\n *   - .generateMap()\n *     Returns a v3 source map.\n */\nmodule.exports = function flowRemoveTypes(source, options) {\n  // Options\n  var all = Boolean(options && options.all);\n  if (options && options.checkPragma) {\n    throw new Error(\n      'flow-remove-types: the \"checkPragma\" option has been replaced by \"all\".',\n    );\n  }\n\n  // If there's no @flow or @noflow flag, then expect no annotation.\n  var pragmaStart = source.indexOf('@' + 'flow');\n  var pragmaSize = 5;\n  if (pragmaStart === -1) {\n    pragmaStart = source.indexOf('@' + 'noflow');\n    pragmaSize = 7;\n    if (pragmaStart === -1 && !all) {\n      return resultPrinter(options, source);\n    }\n  }\n\n  // This parse configuration is intended to be as permissive as possible.\n  var ast = parse(source, {flow: all ? 'all' : 'detect', tokens: true});\n","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/facebook/flow/blob/f88ac94bcf6992f5d5a158854d94613ebb92c6e6/packages/flow-remove-types/index.js#L29-L65","documentation":"Thrown by flow-remove-types' main transform function when the options object contains a `checkPragma` key. In v1.x, `checkPragma: false` told the tool to strip types from every file; v2.x removed that option and replaced it with the inverted `all` option (`all: true` transforms every file, otherwise only files with an @flow/@noflow pragma are processed). The check fires before any parsing, so nothing runs until the config is fixed.","triggerScenarios":"Calling `require('flow-remove-types')(source, {checkPragma: ...})` (or flow-remove-types/register with the same options) with any value of checkPragma present, e.g. `{checkPragma: false}` left over from a 1.x setup; babel/jest configs that forward the whole options object.","commonSituations":"Upgrading flow-remove-types (or @babel dependencies that embed it) from 1.x to 2.x without updating build scripts; copied StackOverflow/codemod configs written for the old API; monorepos where one package was upgraded and its config is shared.","solutions":["Remove `checkPragma` from the options object entirely.","If you relied on `checkPragma: false` (transform files without a pragma), switch to `all: true`.","If you relied on `checkPragma: true` (default pragma detection), pass no option - that is the v2 default.","Grep the repo for `checkPragma` to catch every transform/register entry point."],"exampleFix":"// before\nrequire('flow-remove-types/register')({checkPragma: false});\n\n// after\nrequire('flow-remove-types/register')({all: true});","handlingStrategy":"validation","validationCode":"function sanitizeFlowRemoveTypesOptions(options) {\n  if (!options || !('checkPragma' in options)) return options;\n  const {checkPragma, ...rest} = options;\n  // v1 checkPragma:false meant transform everything -> v2 all:true\n  if (checkPragma === false) rest.all = true;\n  return rest;\n}\n\n// use\nconst out = flowRemoveTypes(source, sanitizeFlowRemoveTypesOptions(opts));","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Grep for 'checkPragma' after every flow-remove-types major upgrade.","Keep transform options in one shared module so there is a single place to migrate.","Add a smoke test that calls the transform with your production options at startup."],"tags":["flow","flow-remove-types","options","migration","breaking-change"],"backgroundTag":"deprecated-option-replaced","analyzedSha":"f88ac94bcf6992f5d5a158854d94613ebb92c6e6","analyzedAt":"2026-08-20T10:41:37.992Z","contentChangedAt":"2026-08-20T10:41:37.992Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}