Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I use Type Augmentation in Spartacus 2.1?

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?

like image 233
Rune Claeys Avatar asked Nov 18 '25 18:11

Rune Claeys


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

like image 129
Jerry Avatar answered Nov 21 '25 08:11

Jerry