You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, quick question. How are product types and such imported from the Rest API?
I've tried to import them from the RestResources object, as that's the only types being exported, but they do not seem to be useable, unless I'm missing something.
example:
import{RestResources}from"@shopify/shopify-api/rest/admin/2024-01";import{shopify}from'./utils/shopify'// setup of shopify API objfunctiontest(prod: RestResources["Product"]|null): void{console.log("hello world");}(async()=>{// act like session & productId is definedconstprod=awaitshopify.rest.Product.find({session: session,id: productId})test(prod);})
This would result in the following error, as the types do not match:
- error TS2345: Argument of type 'Product' is not assignable to parameter of type 'typeof Product'.
Type 'Product' is missing the following properties from type 'typeof Product': prototype, apiVersion, hasOne, hasMany, and 16 more.
The text was updated successfully, but these errors were encountered:
By using the InstanceType utility, you can define the prod parameter as being an instance of that class. While still a little more complicated than it has to be, this might unblock you.
I'll keep this open so we can evaluate exporting the classes as types, but there are other things that are going to be higher priority!
Hello, quick question. How are product types and such imported from the Rest API?
I've tried to import them from the
RestResources
object, as that's the only types being exported, but they do not seem to be useable, unless I'm missing something.example:
This would result in the following error, as the types do not match:
The text was updated successfully, but these errors were encountered: