shopify-api-js
shopify-api-js copied to clipboard
question: product types from rest api
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 obj
function test(prod: RestResources["Product"] | null): void {
console.log("hello world");
}
(async () => {
// act like session & productId is defined
const prod = await shopify.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.