{
 "action": "Not for automatic application — format removed: there is no replacement to apply. Show this correction to the user as a lead. ts.ScriptTarget is not available in typescript 7.0.2; remove or replace this use. The same code works on typescript 6.0.2: pin a version before 7.0.2 if you cannot change the code.",
 "alternatives": [
  {
   "action": "Not for automatic application — the patched example does not run on 7.0.2: exit code 1, TypeError: Cannot read properties of undefined (reading 'CommonJS'). Show this correction to the user as a lead. Replace the old line with the new one; the rest of the code can stay.",
   "applicability": {
    "exit_code": 1,
    "line": 35,
    "method": "literal_patch",
    "occurrences": 1,
    "patched_sha": "6cb2b9f9a3bd",
    "reason": "the patched example does not run on 7.0.2: exit code 1, TypeError: Cannot read properties of undefined (reading 'CommonJS')",
    "run_on": "7.0.2",
    "status": "fails"
   },
   "by_notes": false,
   "changelog_ref": {
    "quote": "",
    "url": ""
   },
   "confirmations": 3,
   "detect": [
    "ts.ScriptTarget.ES2020"
   ],
   "equivalence": "same",
   "format": "replace",
   "kind": "changed",
   "right": "target: \"ES2020\",",
   "script_right": "#!/usr/bin/env node\n\"use strict\";\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nconst ts = require(\"typescript\");\n\nconst projectDir = \"/tmp/alias-demo\";\nconst srcDir = path.join(projectDir, \"src\");\nconst utilsDir = path.join(srcDir, \"utils\");\n\n// Start from a clean project directory\nfs.rmSync(projectDir, { recursive: true, force: true });\nfs.mkdirSync(utilsDir, { recursive: true });\n\n// Source files\nfs.writeFileSync(\n  path.join(utilsDir, \"math.ts\"),\n  `export function add(a: number, b: number): number {\n  return a + b;\n}\n`\n);\n\nfs.writeFileSync(\n  path.join(srcDir, \"index.ts\"),\n  `import { add } from \"@/utils/math\";\n\nconsole.log(add(2, 3));\n`\n);\n\n// Compiler options: \"@/*\" -> \"./src/*\" (relative to the project root; baseUrl is no longer supported)\nconst compilerOptions = {\n  target: \"ES2020\",\n  module: \"CommonJS\",\n  moduleResolution: \"node\",\n  paths: {\n    \"@/*\": [\"./src/*\"],\n  },\n};\n\n// Also write an equivalent tsconfig.json for the demo project\nfs.writeFileSync(\n  path.join(projectDir, \"tsconfig.json\"),\n  JSON.stringify(\n    {\n      compilerOptions: {\n        target: \"ES2020\",\n        module: \"CommonJS\",\n        moduleResolution: \"node\",\n        paths: { \"@/*\": [\"./src/*\"] },\n      },\n      include: [\"src\"],\n    },\n    null,\n    2\n  ) + \"\\n\"\n);\n\n// Minimal \"paths\"-based module resolution (typescript 7 no longer exposes resolveModuleName)\nfunction resolveModuleName(moduleName, containingFile, options, rootDir) {\n  const extensions = [\".ts\", \".tsx\", \".d.ts\"];\n  const isFile = (p) => fs.existsSync(p) && fs.statSync(p).isFile();\n  const tryResolve = (candidate) => {\n    if (isFile(candidate)) return candidate;\n    for (const ext of extensions) {\n      if (isFile(candidate + ext)) return candidate + ext;\n    }\n    for (const ext of extensions) {\n      const indexFile = path.join(candidate, \"index\" + ext);\n      if (isFile(indexFile)) return indexFile;\n    }\n    return undefined;\n  };\n\n  for (const [pattern, targets] of Object.entries(options.paths || {})) {\n    const starIndex = pattern.indexOf(\"*\");\n    let matched;\n    if (starIndex === -1) {\n      if (pattern !== moduleName) continue;\n      matched = \"\";\n    } else {\n      const prefix = pattern.slice(0, starIndex);\n      const suffix = pattern.slice(starIndex + 1);\n      if (\n        !moduleName.startsWith(prefix) ||\n        !moduleName.endsWith(suffix) ||\n        moduleName.length < prefix.length + suffix.length\n      ) {\n        continue;\n      }\n      matched = moduleName.slice(prefix.length, moduleName.length - suffix.length);\n    }\n    for (const target of targets) {\n      const candidate = path.resolve(rootDir, target.replace(\"*\", matched));\n      const resolvedFileName = tryResolve(candidate);\n      if (resolvedFileName) {\n        return { resolvedModule: { resolvedFileName } };\n      }\n    }\n  }\n\n  if (moduleName.startsWith(\".\")) {\n    const resolvedFileName = tryResolve(\n      path.resolve(path.dirname(containingFile), moduleName)\n    );\n    if (resolvedFileName) {\n      return { resolvedModule: { resolvedFileName } };\n    }\n  }\n\n  return { resolvedModule: undefined };\n}\n\n// Resolve \"@/utils/math\" as imported from src/index.ts\nconst containingFile = path.join(srcDir, \"index.ts\");\nconst result = resolveModuleName(\n  \"@/utils/math\",\n  containingFile,\n  compilerOptions,\n  projectDir\n);\n\nif (result.resolvedModule) {\n  console.log(path.resolve(result.resolvedModule.resolvedFileName));\n} else {\n  console.error(\"Failed to resolve module '@/utils/math'\");\n  process.exitCode = 1;\n}",
   "script_wrong": "#!/usr/bin/env node\n\"use strict\";\n\nconst fs = require(\"fs\");\nconst path = require(\"path\");\nconst ts = require(\"typescript\");\n\nconst projectDir = \"/tmp/alias-demo\";\nconst srcDir = path.join(projectDir, \"src\");\nconst utilsDir = path.join(srcDir, \"utils\");\n\n// Start from a clean project directory\nfs.rmSync(projectDir, { recursive: true, force: true });\nfs.mkdirSync(utilsDir, { recursive: true });\n\n// Source files\nfs.writeFileSync(\n  path.join(utilsDir, \"math.ts\"),\n  `export function add(a: number, b: number): number {\n  return a + b;\n}\n`\n);\n\nfs.writeFileSync(\n  path.join(srcDir, \"index.ts\"),\n  `import { add } from \"@/utils/math\";\n\nconsole.log(add(2, 3));\n`\n);\n\n// Compiler options: \"@/*\" -> \"src/*\"\nconst compilerOptions = {\n  target: ts.ScriptTarget.ES2020,\n  module: ts.ModuleKind.CommonJS,\n  moduleResolution: ts.ModuleResolutionKind.Node10 ?? ts.ModuleResolutionKind.NodeJs,\n  baseUrl: projectDir,\n  paths: {\n    \"@/*\": [\"src/*\"],\n  },\n};\n\n// Also write an equivalent tsconfig.json for the demo project\nfs.writeFileSync(\n  path.join(projectDir, \"tsconfig.json\"),\n  JSON.stringify(\n    {\n      compilerOptions: {\n        target: \"ES2020\",\n        module: \"CommonJS\",\n        moduleResolution: \"node\",\n        baseUrl: \".\",\n        paths: { \"@/*\": [\"src/*\"] },\n      },\n      include: [\"src\"],\n    },\n    null,\n    2\n  ) + \"\\n\"\n);\n\n// Resolve \"@/utils/math\" as imported from src/index.ts\nconst containingFile = path.join(srcDir, \"index.ts\");\nconst result = ts.resolveModuleName(\n  \"@/utils/math\",\n  containingFile,\n  compilerOptions,\n  ts.sys\n);\n\nif (result.resolvedModule) {\n  console.log(path.resolve(result.resolvedModule.resolvedFileName));\n} else {\n  console.error(\"Failed to resolve module '@/utils/math'\");\n  process.exitCode = 1;\n}",
   "seen_in_models": [
    "claude-sonnet-5-5",
    "gpt-6.1-sol",
    "gemini-3.8-flash"
   ],
   "wrong": "target: ts.ScriptTarget.ES2020,"
  },
  {
   "action": "Not for automatic application — the patched example does not run on 7.0.2: exit code 1, ReferenceError: stripTypeScriptTypes is not defined. Show this correction to the user as a lead. Review before applying: this fix runs on typescript 7.0.2, but its printed output differs from what the original printed on 6.0.2 (observed stdout of one example) — it may do different work. Rewrite the block as shown; the failing call does not appear in the new version of the block.",
   "applicability": {
    "exit_code": 1,
    "line": 18,
    "method": "literal_patch",
    "occurrences": 1,
    "patched_sha": "a519cef84355",
    "reason": "the patched example does not run on 7.0.2: exit code 1, ReferenceError: stripTypeScriptTypes is not defined",
    "run_on": "7.0.2",
    "status": "fails"
   },
   "by_notes": true,
   "changelog_ref": {
    "quote": "target: es5 is no longer supported.",
    "url": "https://github.com/microsoft/TypeScript/releases/tag/v7.0.2"
   },
   "confirmations": 2,
   "detect": [
    "ts.ScriptTarget.ES5"
   ],
   "equivalence": "differs",
   "format": "fragment",
   "kind": "behavior_changed",
   "right": "const result = {\noutputText: stripTypeScriptTypes(source, {\nmode: 'transform',\nsourceUrl: 'example.ts'\n})\n};",
   "script_right": "'use strict';\n\nconst ts = require('typescript');\nconst { stripTypeScriptTypes } = require('node:module');\n\nconst source = [\n  'class Greeter {',\n  '  constructor(private name: string) {}',\n  '',\n  '  greet(): string {',\n  '    const format = (name: string): string => `Hello, ${name}!`;',\n  '    return format(this.name);',\n  '  }',\n  '}',\n  '',\n  'console.log(new Greeter(\"World\").greet());'\n].join('\\n');\n\n// typescript 7.0.2 only exports `version` and `versionMajorMinor`, so\n// `transpileModule` and `ScriptTarget` are unavailable. ES5 output is also no\n// longer supported. Node.js's built-in type stripping ('transform' mode\n// handles `private` parameter properties) produces equivalent modern JS.\nconst result = {\n  outputText: stripTypeScriptTypes(source, {\n    mode: 'transform',\n    sourceUrl: 'example.ts'\n  })\n};\n\nconsole.log(result.outputText);",
   "script_wrong": "'use strict';\n\nconst ts = require('typescript');\n\nconst source = [\n  'class Greeter {',\n  '  constructor(private name: string) {}',\n  '',\n  '  greet(): string {',\n  '    const format = (name: string): string => `Hello, ${name}!`;',\n  '    return format(this.name);',\n  '  }',\n  '}',\n  '',\n  'console.log(new Greeter(\"World\").greet());'\n].join('\\n');\n\nconst result = ts.transpileModule(source, {\n  compilerOptions: {\n    target: ts.ScriptTarget.ES5,\n    module: ts.ModuleKind.CommonJS,\n    newLine: ts.NewLineKind.LineFeed\n  },\n  fileName: 'example.ts'\n});\n\nconsole.log(result.outputText);",
   "seen_in_models": [
    "gpt-6.1-sol"
   ],
   "wrong": "const result = ts.transpileModule(source, {\ncompilerOptions: {\ntarget: ts.ScriptTarget.ES5,\nmodule: ts.ModuleKind.CommonJS,\nnewLine: ts.NewLineKind.LineFeed\n},\nfileName: 'example.ts'\n});"
  },
  {
   "action": "Not for automatic application — the patched example does not run on 7.0.2: exit code 1, ReferenceError: stripTypeScriptTypes is not defined. Show this correction to the user as a lead. Review before applying: this fix runs on typescript 7.0.2, but its printed output differs from what the original printed on 6.0.2 (observed stdout of one example) — it may do different work. Rewrite the block as shown; the failing call does not appear in the new version of the block.",
   "applicability": {
    "exit_code": 1,
    "line": 14,
    "method": "literal_patch",
    "occurrences": 1,
    "patched_sha": "19a55afb986b",
    "reason": "the patched example does not run on 7.0.2: exit code 1, ReferenceError: stripTypeScriptTypes is not defined",
    "run_on": "7.0.2",
    "status": "fails"
   },
   "by_notes": true,
   "changelog_ref": {
    "quote": "target: es5 is no longer supported.",
    "url": "https://github.com/microsoft/TypeScript/releases/tag/v7.0.2"
   },
   "confirmations": 1,
   "detect": [
    "ts.ScriptTarget.ES5"
   ],
   "equivalence": "differs",
   "format": "fragment",
   "kind": "behavior_changed",
   "right": "const result = {\noutputText: stripTypeScriptTypes(source, { mode: \"transform\" })\n};",
   "script_right": "const ts = require(\"typescript\");\nconst { stripTypeScriptTypes } = require(\"node:module\");\n\nconst source = `\nclass Greeter {\n  constructor(private name: string) {}\n\n  greet = (): string => \\`Hello, \\${this.name}!\\`;\n}\n\nconst greeter = new Greeter(\"World\");\nconsole.log(greeter.greet());\n`;\n\nconst result = {\n  outputText: stripTypeScriptTypes(source, { mode: \"transform\" })\n};\n\nconsole.log(result.outputText);",
   "script_wrong": "const ts = require(\"typescript\");\n\nconst source = `\nclass Greeter {\n  constructor(private name: string) {}\n\n  greet = (): string => \\`Hello, \\${this.name}!\\`;\n}\n\nconst greeter = new Greeter(\"World\");\nconsole.log(greeter.greet());\n`;\n\nconst result = ts.transpileModule(source, {\n  compilerOptions: {\n    target: ts.ScriptTarget.ES5,\n    module: ts.ModuleKind.CommonJS\n  }\n});\n\nconsole.log(result.outputText);",
   "seen_in_models": [
    "gpt-6.1-sol"
   ],
   "wrong": "const result = ts.transpileModule(source, {\ncompilerOptions: {\ntarget: ts.ScriptTarget.ES5,\nmodule: ts.ModuleKind.CommonJS\n}\n});"
  }
 ],
 "applicability": {
  "method": "literal_patch",
  "reason": "format removed: there is no replacement to apply",
  "run_on": "7.0.2",
  "status": "not_applicable"
 },
 "by_notes": false,
 "changelog_ref": {
  "quote": "",
  "url": ""
 },
 "confirmations": {
  "failed": 0,
  "worked": 22
 },
 "detect": [
  "ts.ScriptTarget.ES2020"
 ],
 "ecosystem": "npm",
 "equivalence": "same",
 "error_kind": "undefined_prop",
 "error_signature": {
  "message": "Cannot read properties of undefined (reading 'ES2020')",
  "norm": "undefined_prop:es2020",
  "type": "TypeError"
 },
 "first_seen": "2026-10-20T16:11:13+00:00",
 "format": "removed",
 "format_version": 2,
 "id": "npm/typescript/7.0.2/0001",
 "kind": "removed",
 "license": "https://creativecommons.org/licenses/by/4.0/",
 "package": "typescript",
 "proof": {
  "applicability": {
   "method": "literal_patch",
   "reason": "format removed: there is no replacement to apply",
   "run_on": "7.0.2",
   "status": "not_applicable"
  },
  "auto_apply": false,
  "auto_apply_reason": "the patch gives not_applicable when applied word for word",
  "auto_apply_rule": "Automatic application is allowed only when proof.equivalent is true and proof.applicability.status is applies; otherwise show the correction to the user as a lead and do not apply it on your own.",
  "equivalence": "same",
  "equivalent": true,
  "fails_on": "7.0.2",
  "fixed_on": "7.0.2",
  "level": "differential",
  "method": {
   "fix_on": "7.0.2",
   "name": "stdout_match",
   "normalization": "lines stripped, blank lines dropped, runs of whitespace collapsed; memory addresses, timestamps and temporary paths masked",
   "original_on": "6.0.2",
   "scope": "the observable stdout of one example script; return values, files, other inputs and exception types are not compared, so a match is not a proof of equivalent behaviour"
  },
  "script_right": "const fs = require(\"node:fs\");\nconst path = require(\"node:path\");\nconst ts = require(\"typescript\");\n\nconst projectDir = \"/tmp/alias-demo\";\nconst srcDir = path.join(projectDir, \"src\");\nconst indexFile = path.join(srcDir, \"index.ts\");\n\nfs.mkdirSync(path.join(srcDir, \"utils\"), { recursive: true });\n\nfs.writeFileSync(\n  path.join(srcDir, \"utils\", \"math.ts\"),\n  \"export const add = (a: number, b: number): number => a + b;\\n\"\n);\nfs.writeFileSync(\n  indexFile,\n  'import { add } from \"@/utils/math\";\\nconsole.log(add(2, 3));\\n'\n);\n\nconst compilerOptions = {\n  paths: {\n    \"@/*\": [\"./src/*\"],\n  },\n};\n\nfunction resolveModuleName(moduleName, containingFile, options) {\n  const extensions = [\".ts\", \".tsx\", \".d.ts\"];\n  const tryFile = (candidate) => {\n    for (const ext of extensions) {\n      const file = candidate + ext;\n      if (fs.existsSync(file) && fs.statSync(file).isFile()) return file;\n    }\n    for (const ext of extensions) {\n      const file = path.join(candidate, \"index\" + ext);\n      if (fs.existsSync(file) && fs.statSync(file).isFile()) return file;\n    }\n    return undefined;\n  };\n  for (const [pattern, targets] of Object.entries(options.paths || {})) {\n    const star = pattern.indexOf(\"*\");\n    let matched;\n    if (star === -1) {\n      if (pattern === moduleName) matched = \"\";\n    } else {\n      const prefix = pattern.slice(0, star);\n      const suffix = pattern.slice(star + 1);\n      if (\n        moduleName.startsWith(prefix) &&\n        moduleName.endsWith(suffix) &&\n        moduleName.length >= prefix.length + suffix.length\n      ) {\n        matched = moduleName.slice(prefix.length, moduleName.length - suffix.length);\n      }\n    }\n    if (matched === undefined) continue;\n    for (const target of targets) {\n      const candidate = path.resolve(projectDir, target.replace(\"*\", matched));\n      const resolvedFileName = tryFile(candidate);\n      if (resolvedFileName) return { resolvedModule: { resolvedFileName } };\n    }\n  }\n  return { resolvedModule: undefined };\n}\n\nconst { resolvedModule } = resolveModuleName(\n  \"@/utils/math\",\n  indexFile,\n  compilerOptions\n);\n\nif (!resolvedModule) {\n  throw new Error(\"Could not resolve @/utils/math\");\n}\n\nconsole.log(path.resolve(resolvedModule.resolvedFileName));",
  "script_wrong": "const fs = require(\"node:fs\");\nconst path = require(\"node:path\");\nconst ts = require(\"typescript\");\n\nconst projectDir = \"/tmp/alias-demo\";\nconst srcDir = path.join(projectDir, \"src\");\nconst indexFile = path.join(srcDir, \"index.ts\");\n\nfs.mkdirSync(path.join(srcDir, \"utils\"), { recursive: true });\n\nfs.writeFileSync(\n  path.join(srcDir, \"utils\", \"math.ts\"),\n  \"export const add = (a: number, b: number): number => a + b;\\n\"\n);\nfs.writeFileSync(\n  indexFile,\n  'import { add } from \"@/utils/math\";\\nconsole.log(add(2, 3));\\n'\n);\n\nconst compilerOptions = {\n  target: ts.ScriptTarget.ES2020,\n  module: ts.ModuleKind.CommonJS,\n  moduleResolution: ts.ModuleResolutionKind.Node10,\n  baseUrl: projectDir,\n  paths: {\n    \"@/*\": [\"src/*\"],\n  },\n};\n\nconst { resolvedModule } = ts.resolveModuleName(\n  \"@/utils/math\",\n  indexFile,\n  compilerOptions,\n  ts.sys\n);\n\nif (!resolvedModule) {\n  throw new Error(\"Could not resolve @/utils/math\");\n}\n\nconsole.log(path.resolve(resolvedModule.resolvedFileName));",
  "works_on": "6.0.2"
 },
 "right": "",
 "seen_in_models": [
  "claude-sonnet-5-5",
  "gpt-6.1-sol",
  "gemini-3.8-flash"
 ],
 "seq": 1,
 "slug": "baseurl",
 "source": "pipeline",
 "symbol": "ts.ScriptTarget",
 "updated": "2026-10-27T17:20:00+00:00",
 "url": "https://formachines.ai/errata/npm/typescript/0001-baseurl/",
 "variant_confirmations": 16,
 "variant_models": [
  "gpt-6.1-sol",
  "claude-sonnet-5-5",
  "gemini-3.8-flash"
 ],
 "verified": "sandbox",
 "versions": {
  "changed_in": ">6.0.2,<=7.0.2",
  "fails_on": "7.0.2",
  "works_on": "6.0.2"
 },
 "wrong": "target: ts.ScriptTarget.ES2020,"
}