ソースを参照

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

Michael Bromley 3 年 前
コミット
708feacc19
1 ファイル変更6 行追加2 行削除
  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
 ```TypeScript
 // types.ts
 // 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 {
   interface CustomProductFields {
     infoUrl: string;
     infoUrl: string;
     downloadable: boolean;
     downloadable: boolean;