The load method of hooks fields in smartAction displays a Typescript error as follow:
Package:
![]()
![]()
Do you have any ideas to fix that ?
The load method of hooks fields in smartAction displays a Typescript error as follow:
Package:
![]()
![]()
Do you have any ideas to fix that ?
I would suggest you to remove the @types/forest-express-mongoose, as the forest-express-mongoose@8 embed its own types.
(If the type is still incorrect though, I would be happy to fix it
)
Let me know if that helps
hey @anon39848301 not it does not. I still get this error message
It seems I must type the smartAction I import in the forest-expression-mongoose collection() method with SmartActionOptions
import { mySmartAction } from '../smart-actions/my-smart-action.ts'
collection('account', {
actions: [
mySmartAction
]
})
if I don’t, I get this Typescript error message:
The problem still remains on hooks load method when giving the SmartActionOptions type to my smart action:
export const mySmartAction: SmartActionOptions = {
name: 'my smart action',
...,
hooks: {
load: ({ fields, record }) => {}
}
}
@guillaumejauffret weird indeed.
Looking at the type definition:
hooks is an allowed value in SmartActionOptions, as SmartActionHooks (Here)load is an allowed value in the SmartActionHooks (Here)From the error I can see in your last message, property type seems to have an incorrect value (Allowed single, bulk or global).
Could you share here (Or as DM) your smart action definition so I can check what is happening on my end?
Thanks ![]()
Yes I share it to you in DM
As you can see in the SmartActionLoadHook interface, record does not exist
Ok my bad, I did not understand the issue correctly.
Did you recently migrate to v8?
According to the v8 breaking change documentation (here - last paragraph), we do not provide the record to the hook function anymore (So the matching type seems to be correct).
Ok I had not seen this update sorry.
However @anon39848301 ,
your doc does not seems to be very fresh.
Here you can see how a hook change function is written in your doc

but here is the type definition:
export interface SmartActionChangeHook {
(context: { fields: SmartActionChangeHookField[], changedField: SmartActionChangeHookField, request: SmartActionChangeHookRequest }): SmartActionChangeHookField[] | Promise<SmartActionChangeHookField[]>
}
Indeed, I scratched my head understanding the issue as well. The documentation isn’t clear since it is the very last paragraph + all the examples above are not “good” example to explain the migration.
I’ll do a feedback to the team and update these examples accordingly. Thanks for reporting this ![]()