Forest Typescript: IDE complains about the load hook

Expected behavior

{
    name: 'Add Collection',
    type: 'single',
    fields: [
        {
            field: 'Tracking',
            type: 'Enum',
            enums: [],
            description:
                'Tracking for normal collections.',
            isRequired: true
        }
    ],
    hooks: {
        load: async ({ fields, request }) => {
                    const id = parseInt(request.body.data.attributes.ids[0]);
                    const descriptions = repo.findAll(id);
                    trackingField.enums = descriptions;
                    return fields;
                }
        }
    }

In the above piece of code, visual studio code gives the error:

Type '({ fields, request }: { fields: SmartActionLoadHookField[]; request: SmartActionLoadHookRequest; }) => Promise<SmartActionLoadHookField[]>' is not assignable to type 'SmartActionLoadHook'.
  Type 'Promise<SmartActionLoadHookField[]>' is missing the following properties from type 'SmartActionLoadHookField[]': length, pop, push, concat, and 26 more.ts(2322)
(property) SmartActionHooks.load: Liana.SmartActionLoadHook

I would expect no error as the code itself works fine. Seems to be a typing issue

Actual behavior

IDE finds errors in functional code.

Context

Please provide any relevant information about your setup.

  • Package Version: “forest-express-sequelize”: “^8.0.6”
  • Express Version: “express”: “^4.17.1”
  • Sequelize Version: “sequelize”: “6.6.2”
  • Database Dialect: postgres

Side note

As a side note, why does the forest interface for a smart action field not have a widget as a property?

Hi @SoftwareBridgementKe :wave: welcome to our community. Thank for your feedback, this is indeed an issue. I will open a bug report and we reach you here when the issue are fixed.

1 Like