after generating a discount function settings extension,
and having the docs example used,
the resourcePicker returned from useApi seems to be missing in the types,
the code runs and works but typescript got some types wrong
another type that seems wrong is the props for ProgressIndicator, ts says its missing a required type, but the code seems to work without it, this one is less bothering but it may tell us something about stale type definitions?
The current solution i used (twimc),
was to assert the type like so:
import { ResourcePickerApi } from "@shopify/ui-extensions/build/ts/surfaces/admin/api/resource-picker/resource-picker";
...
const api = useApi(TARGET);
const { applyMetafieldChange, i18n, data, resourcePicker, query } =
api as typeof api & { resourcePicker: ResourcePickerApi };
I’m not sure they are related, because i’m not using app bridge ( afaik, function settings extension doesn’t use app-bridge right?)
also it seems the issue there was that even though resourcePicker is typed and recognized, its missing the return type?
The typescript types are fixed in the latest ui-extensions release!
1 Like