{"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":"Error","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/d1341dac899a79c027762f6b423d896045287620/packages/flow-remove-types/index.js#L29-L65","documentation":"flow-remove-types renamed its checkPragma option to all: both control whether type stripping happens even when no @flow pragma is present. Because the old name would silently do nothing after the rename, the library now throws immediately when it sees checkPragma to force the migration. This is a deliberate API-break guard, not a runtime failure of the stripping logic.","triggerScenarios":"Calling require('flow-remove-types')(src, {checkPragma: true}) (or false) on any version after the rename; using an old config for the Node require hook, webpack or browserify loader, or CLI that still passes checkPragma.","commonSituations":"Upgrading flow-remove-types or the Flow toolchain in a repo whose build config (jest register hook, webpack loader options, gulp task) was written for the pre-rename API; copy-pasted snippets from old blog posts.","solutions":["Replace every checkPragma: X with all: X in code and build config","Search the repo and checked-in configs for 'checkPragma' to catch loader and register options","Pin the pre-rename version only as a temporary stopgap while migrating"],"exampleFix":"// before\nrequire('flow-remove-types')(src, {checkPragma: true});\n\n// after\nrequire('flow-remove-types')(src, {all: true});","handlingStrategy":"validation","validationCode":"function normalizeOptions(options = {}) {\n  if ('checkPragma' in options) {\n    throw new Error('checkPragma was renamed to all; migrate options before calling');\n  }\n  return options;\n}","typeGuard":"const hasMigratedOptions = (o) => o == null || !('checkPragma' in o);","tryCatchPattern":null,"preventionTips":["Search the whole repo (including webpack, jest, and gulp configs) for checkPragma after upgrading","Add a config schema check that rejects unknown option keys","Read the release notes for option renames before bumping flow-remove-types"],"tags":["options","migration","flow-remove-types","deprecated-api"],"backgroundTag":"renamed-library-option","analyzedSha":"d1341dac899a79c027762f6b423d896045287620","analyzedAt":"2026-08-17T00:07:02.212Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}