Shopify / shopify-app-js

MIT License
262 stars 101 forks source link

`product.variants` are not typed correctly when calling `shopify.Product.find()` #773

Open magoz opened 1 year ago

magoz commented 1 year ago

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.

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 })
github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

jakeleventhal commented 1 year ago

This issue is not stale

github-actions[bot] commented 10 months ago

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

magoz commented 10 months ago

This issue is not stale

github-actions[bot] commented 8 months ago

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

jakeleventhal commented 8 months ago

Not stale. Major issue

github-actions[bot] commented 6 months ago

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.

jakeleventhal commented 6 months ago

NOT STALE

paulomarg commented 4 months ago

Hey folks, I've responded to https://github.com/Shopify/shopify-app-js/issues/772#issuecomment-2065124180, let's continue to discuss there so the conversation is in a single issue.

github-actions[bot] commented 2 months ago

We're labeling this issue as stale because there hasn't been any activity on it for 60 days. While the issue will stay open and we hope to resolve it, this helps us prioritize community requests.

You can add a comment to remove the label if it's still relevant, and we can re-evaluate it.