Uncaught TypeError: x?.formatting?.getIndent is not a function at

const x = {
  formatting: { getIndent: "getIndent" },
};

x?.formatting?.getIndent?.();

Uncaught TypeError: x?.formatting?.getIndent is not a function at

Why am I getting this error ? typescript this code it works