Set collection attribute value as null

Feature(s) impacted

I want to create a smart action to Unpublish a news.
The smart action will set the publishedAt column of the news table as NULL
The code used to do this is the following

  collection.addAction('Unpublish news', {
    scope: 'Single',
    execute: async (context, resultBuilder) => {
      await context.collection.update(context.filter, {
        publishedAt: null,

      return resultBuilder.success('News unpublished');

Observed behavior

I get a typescript error on the update “Type ‘null’ is not assignable to type ‘string | undefined’”.
This is because the generated type in the typing.ts file is “string”

Expected behavior

I want the type generated in the typing file to be Date | null or at least string | null


  • Environment name: local
  • Agent (forest package) name & version: "@forestadmin/agent": "^1.0.0", and "@forestadmin/datasource-sql": "^1.0.0",
  • Database type: postgres

Hello @Quentin_Somerville,
I believe you are seeing this behaviour because you have strictNullChecks = true in your typescript configuration.
The typings generated do not support this configuration. Can you switch to strictNullChecks = false ?


Nicolas Moreau

Hello @Nicolas.M
Indeed setting strictNullChecks as false resolve the issue.
But I don’t like this solution as this check is a good check for the rest of the codebase :grin:
I will ignore this error to go further

Hello @Quentin_Somerville,

I’m glad you have a workaround for your issue.
In the meantime, I have opened up a ticket on our side to improve the typings generation on our side for when strickNullCheck=true
I will keep this thread updated with the resolution.



Hello !

The fix for the issue has just been released in the agent nodejs package.
Please upgrade to agent@1.36.19 and let us know if this is working out for you.