How can I use Type Augmentation in Spartacus 2.1?

Viewed 143

The spartacus documentation about Module/type augmentation says it's supported in spartacus 2.1. https://sap.github.io/spartacus-docs/type-augmentation/#page-title

But when I try to extend the ConsentTemplate interface

import { ConsentTemplate } from '@spartacus/core';

declare module '@spartacus/core' {
  interface ConsentTemplate {
    documentUrl?: string;
  }
}

I get this error => error TS2339: Property 'documentUrl' does not exist on type 'ConsentTemplate'.

Is it possible to use type augmentation in Spartacus 2.1? And if so how to make it work?

1 Answers

Type Augmentation is supported in Spartacus 2.1. I tested it in my app.module.ts.

enter image description here

Then in my application code I can see the new extended field "documentUrl" from Visual Studio Code field autocompletion list and use it as other standard fields. enter image description here

Related