{"record":{"id":"3f2144c09bb3a77d","repo":"microsoft/TypeScript","slug":"deprecationerror-name-has-been-deprecated-si","errorCode":null,"errorMessage":"DeprecationError: '${name}' has been deprecated since v${since} and can no longer be used.","messagePattern":"DeprecationError: '(.+?)' has been deprecated since v(.+?) and can no longer be used\\.","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"src/deprecatedCompat/deprecate.ts","lineNumber":34,"sourceCode":"let typeScriptVersion: Version | undefined;\r\n\r\nfunction getTypeScriptVersion() {\r\n    return typeScriptVersion ?? (typeScriptVersion = new Version(version));\r\n}\r\n\r\nfunction formatDeprecationMessage(name: string, error: boolean | undefined, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) {\r\n    let deprecationMessage = error ? \"DeprecationError: \" : \"DeprecationWarning: \";\r\n    deprecationMessage += `'${name}' `;\r\n    deprecationMessage += since ? `has been deprecated since v${since}` : \"is deprecated\";\r\n    deprecationMessage += error ? \" and can no longer be used.\" : errorAfter ? ` and will no longer be usable after v${errorAfter}.` : \".\";\r\n    deprecationMessage += message ? ` ${formatStringFromArgs(message, [name])}` : \"\";\r\n    return deprecationMessage;\r\n}\r\n\r\nfunction createErrorDeprecation(name: string, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) {\r\n    const deprecationMessage = formatDeprecationMessage(name, /*error*/ true, errorAfter, since, message);\r\n    return () => {\r\n        throw new TypeError(deprecationMessage);\r\n    };\r\n}\r\n\r\nfunction createWarningDeprecation(name: string, errorAfter: Version | undefined, since: Version | undefined, message: string | undefined) {\r\n    let hasWrittenDeprecation = false;\r\n    return () => {\r\n        if (enableDeprecationWarnings && !hasWrittenDeprecation) {\r\n            Debug.log.warn(formatDeprecationMessage(name, /*error*/ false, errorAfter, since, message));\r\n            hasWrittenDeprecation = true;\r\n        }\r\n    };\r\n}\r\n\r\nexport function createDeprecation(name: string, options: DeprecationOptions & { error: true; }): () => never;\r\nexport function createDeprecation(name: string, options?: DeprecationOptions): () => void;\r\nexport function createDeprecation(name: string, options: DeprecationOptions = {}) {\r\n    const version = typeof options.typeScriptVersion === \"string\" ? new Version(options.typeScriptVersion) : options.typeScriptVersion ?? getTypeScriptVersion();\r\n    const errorAfter = typeof options.errorAfter === \"string\" ? new Version(options.errorAfter) : options.errorAfter;\r","sourceCodeStart":16,"sourceCodeEnd":52,"githubUrl":"https://github.com/microsoft/TypeScript/blob/b465fdbfe175304d9b977da137b2c178ae1091d3/src/deprecatedCompat/deprecate.ts#L16-L52","documentation":"Thrown by the `createErrorDeprecation` factory in `src/deprecatedCompat/deprecate.ts` for APIs marked with `error: true`. Unlike warning deprecations (which only log once), error deprecations throw a `TypeError` on every call, with a message naming the API, the deprecation `since` version, and any custom message. It is the hard-removal gate for APIs that have aged out of the supported window.","triggerScenarios":"Calling a `deprecatedCompat` API whose deprecation entry has `error: true` (fully removed). The factory replaces the exported function with a thunk that always throws. Reached by importing and invoking any such API (e.g. removed legacy compiler options/APIs).","commonSituations":"Upgrading TypeScript to a version that hard-removes an API you were still using; relying on `@knipignore`-marked legacy surfaces; tooling pinning to old behavior that has now been gated out.","solutions":["Migrate off the deprecated API to its documented replacement (the deprecation `message` usually names it).","If a migration path is incomplete, pin to the last TypeScript version where the API was a warning rather than an error.","Search the codebase for the deprecated `name` and replace all call sites.","Consult the release notes for the version cited in `since`."],"exampleFix":"// before\nconst r = ts.someRemovedApi(args);   // throws DeprecationError\n// after\nconst r = ts.replacementApi(args);     // per the deprecation message / release notes","handlingStrategy":"validation","validationCode":"// Before upgrading, grep for deprecated usages flagged by the previous (warning) version:\n//   rg -n \"someRemovedApi\" src/\n// and migrate each call site listed.","typeGuard":null,"tryCatchPattern":"try {\n  ts.someRemovedApi(args);\n} catch (e) {\n  if (e instanceof TypeError && /DeprecationError/.test(String(e))) {\n    // migrate to the replacement; do not silently swallow\n  } else throw e;\n}","preventionTips":["Treat deprecation warnings as build failures before they become errors.","Run the compiler upgrade on a branch and fix every deprecation warning first.","Remove usages of `deprecatedCompat` surfaces ahead of version bumps."],"tags":["deprecation","compat","versioning","migration"],"backgroundTag":null,"analyzedSha":"b465fdbfe175304d9b977da137b2c178ae1091d3","analyzedAt":"2026-08-12T05:38:42.698Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}