medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
25.92k stars 2.6k forks source link

Docs(Code Issue): TypeScript Error #9226

Closed amaster507 closed 1 month ago

amaster507 commented 1 month 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 1 month 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>)
shahednasser commented 1 month ago

Thanks for reporting this! wIll look into it