shopify-api-js
shopify-api-js copied to clipboard
`product.variants` are not typed correctly when calling `shopify.Product.find()`
Issue summary
product.variants
are typed as [key: string]: any
when calling shopify.Product.find()
.
I can see that types for variants exist in the codebase, but I guess there are not inferred or applied correctly.
-
@shopify/shopify-api
version: 2023-04 - Node version: 18.12.1
- Operating system: MacOS 12.6.5
Expected behavior
product.variants
to be typed strongly typed.
Actual behavior
const session = shopify.session.customAppSession('shop.myshopify.com')
const product = await shopify.rest.Product.find({ session, id })
if(product?.variants) {
console.log(product.variants)
// ^? (property) Product.variants: Variant[] | {
// [key: string]: any;
// }
}
Steps to reproduce the problem
import { shopifyApi, ApiVersion, LogSeverity } from '@shopify/shopify-api'
import { restResources } from '@shopify/shopify-api/rest/admin/2023-04'
const shopify = shopifyApi({
apiVersion: ApiVersion.April23,
apiSecretKey: process.env.SHOPIFY_API_SECRET_KEY ?? '',
adminApiAccessToken: process.env.SHOPIFY_ADMIN_API_ACCESS_TOKEN ?? '',
isCustomStoreApp: true,
isEmbeddedApp: false,
hostName: 'shop.myshopify.com',
restResources
})
const session = shopify.session.customAppSession('shop.myshopify.com')
const product = await shopify.rest.Product.find({ session, id })