4

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 Answers1

1

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

i042416
  • 356
  • 1
  • 3
  • 1
    Thanks for the response, I do get the intellisense on objects of the ConsentTemplate type. But my compiler throws this error nevertheless: ERROR in error TS2688: Cannot find type definition file for './src/common/typings/consent.module.ts'. src/modules/consent/containers/consent-container/consent-container.component.ts:77:36 - error TS2339: Property 'documentUrl' does not exist on type 'ConsentTemplate'. 77 `${consentTemplate.description}` ~~~~~~~~~~~ – Rune Claeys Mar 01 '21 at 09:56