{"record":{"id":"a9bfa34e1dc743a1","repo":"facebook/lexical","slug":"override-for-name-specifies-replace-without","errorCode":null,"errorMessage":"Override for ${name} specifies 'replace' without 'withKlass'. 'withKlass' will be required in a future version.","messagePattern":"Override for (.+?) specifies 'replace' without 'withKlass'\\. 'withKlass' will be required in a future version\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"packages/lexical/src/LexicalEditor.ts","lineNumber":1022,"sourceCode":"      // For the side-effect of filling in the static methods\n      void getStaticNodeConfig(klass);\n\n      // Ensure custom nodes implement required methods and replaceWithKlass is instance of base klass.\n      if (__DEV__) {\n        // ArtificialNode__DO_NOT_USE can get renamed, so we use the type\n        const name = klass.name;\n        const nodeType =\n          hasOwnStaticMethod(klass, 'getType') && klass.getType();\n\n        if (replaceWithKlass) {\n          invariant(\n            replaceWithKlass.prototype instanceof klass,\n            \"%s doesn't extend the %s\",\n            replaceWithKlass.name,\n            name,\n          );\n        } else if (replace) {\n          console.warn(\n            `Override for ${name} specifies 'replace' without 'withKlass'. 'withKlass' will be required in a future version.`,\n          );\n        }\n        if (\n          name !== 'RootNode' &&\n          nodeType !== 'root' &&\n          nodeType !== 'artificial' &&\n          // This is mostly for the unit test suite which\n          // uses LexicalNode in an otherwise incorrect way\n          // by mocking its static getType\n          klass !== LexicalNode\n        ) {\n          (['getType', 'clone'] as const).forEach(method => {\n            if (!hasOwnStaticMethod(klass, method)) {\n              console.warn(`${name} must implement static \"${method}\" method`);\n            }\n          });\n          if (!hasOwnStaticMethod(klass, 'importJSON')) {","sourceCodeStart":1004,"sourceCodeEnd":1040,"githubUrl":"https://github.com/facebook/lexical/blob/76a22dcba981b46119fcec45f935270707e26a57/packages/lexical/src/LexicalEditor.ts#L1004-L1040","documentation":"When createEditor processes node overrides that use the legacy `replace` option without a `withKlass`, Lexical cannot statically know which class the override replaces, so it warns that 'withKlass' will become required. The override still works today, but the behavior is deprecated and will break in a future major version.","triggerScenarios":"createEditor (or buildEditorFromExtensions config) is given an entry like { replace: SomeNode, ... } (or override with replace: true) lacking the withKlass property, and validation reaches the `else if (replace)` branch.","commonSituations":"Upgrading Lexical and porting old node override configs; copy-pasting deprecated override examples from older docs; third-party extensions emitting legacy replace overrides.","solutions":["Add withKlass to the override, naming the class being replaced: { replace: ..., withKlass: OriginalNode }.","Where possible, replace the legacy override pattern with a proper node subclass registered via nodes: or an extension.","Search the codebase for `replace:` node overrides and update each one.","Watch the Lexical changelog for the version where withKlass becomes mandatory."],"exampleFix":"// before\noverride: { replace: true, extend: klass }\n// after\noverride: { replace: true, withKlass: klass, extend: klass }","handlingStrategy":"validation","validationCode":"for (const [name, o] of Object.entries(nodeOverrides)) {\n  if ('replace' in o && !('withKlass' in o)) {\n    console.warn(`Override ${name} uses legacy replace; add withKlass before next major.`);\n  }\n}","typeGuard":"function hasWithKlass(o: object): o is { withKlass: Klass<LexicalNode> } {\n  return 'withKlass' in o;\n}","tryCatchPattern":"null","preventionTips":["Always pair replace: with withKlass in node overrides.","Prefer proper subclasses/extensions over replace overrides.","Grep CI for `replace:` overrides lacking withKlass.","Track the changelog for when withKlass becomes required."],"tags":["deprecation","node-override","configuration","api-change"],"backgroundTag":"deprecated-replace-override","analyzedSha":"76a22dcba981b46119fcec45f935270707e26a57","analyzedAt":"2026-08-31T21:45:54.792Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}