Jelajahi Sumber

docs(core): Add docs on safe declaration merging for custom field types

Michael Bromley 3 tahun lalu
induk
melakukan
708feacc19
1 mengubah file dengan 6 tambahan dan 2 penghapusan
  1. 6 2
      docs/content/developer-guide/customizing-models.md

+ 6 - 2
docs/content/developer-guide/customizing-models.md

@@ -204,9 +204,13 @@ However, this sacrifices type safety. To make our custom fields type-safe we can
 
 ```TypeScript
 // types.ts
-import { CustomProductFields } from '@vendure/core';
 
-declare module '@vendure/core' {
+// Note: we are using deep a import here, rather than importing from `@vendure/core` due to 
+// a possible bug in TypeScript (https://github.com/microsoft/TypeScript/issues/46617) which
+// causes issues when multiple plugins extend the same custom fields interface.
+import { CustomProductFields } from '@vendure/core/dist/entity/custom-entity-fields';
+
+declare module '@vendure/core/dist/entity/custom-entity-fields' {
   interface CustomProductFields {
     infoUrl: string;
     downloadable: boolean;