medusajs / medusa

Building blocks for digital commerce
https://medusajs.com
MIT License
24.7k stars 2.44k forks source link

Docs(Code Issue): TypeScript Error #9226

Open amaster507 opened 3 hours ago

amaster507 commented 3 hours ago

What Medusa version and documentation are you using?

v2

Preliminary Checks

Issue Summary

URL: https://docs.medusajs.com/v2/customization/integrate-systems/service#1-create-service

moduleDef.options is not strongly typed, so the line:

this.options_ = moduleDef.options

produces ts error:

Property 'apiKey' is missing in type 'Record<string, unknown>' but required in type 'BrandClientOptions'. ts(2741) client.ts(5, 5): 'apiKey' is declared here.

How can this issue be resolved?

  1. add the code as BrandClientOptions

Are you interested in working on this issue?

amaster507 commented 3 hours ago

Also the line:

async createBrand(brand: Record<string, string>)

later is the culprit for a type error because the value type of string is too strict for brand which has properties that are Date values.

To fix this, change the line to allow either string | Date values like:

async createBrand(brand: Record<string, string | Date>)