You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
With strict-null check enabled - you cannot use null as prop for any meta block. All my meta fields are coming from Static/ServerSide Props and there is a catch - next refuses to serialize undefined, meaning that I have to either filter out all undefined values from objects (and there is no easy way to do it recursively and type-safe), or replace them with 0 / empty string (depending on field type).
Reproduction
importtype{OpenGraphMedia}from'next-set/lib/types';/*TS2322: Type 'number | null' is not assignable to type 'number | undefined'. Type 'null' is not assignable to type 'number | undefined'. The expected type comes from property 'width' which is declared here on type 'OpenGraphMedia'*/constimages: OpenGraphMedia={url: img.sourceUrl,width: img.mediaDetails?.width||null,height: img.mediaDetails?.height||null,};
Additional context
I checked couple of files in this repo and it seems like value is implicitly typecasted to boolean, and null is falsy in a same way undefined is. Of course, some investigation is required, but it seems like an extremely easy fix.
The text was updated successfully, but these errors were encountered:
Duplicate of #840 - which was closed by stale bot
Describe the bug
With strict-null check enabled - you cannot use null as prop for any meta block. All my meta fields are coming from Static/ServerSide Props and there is a catch - next refuses to serialize undefined, meaning that I have to either filter out all undefined values from objects (and there is no easy way to do it recursively and type-safe), or replace them with
0
/empty string
(depending on field type).Reproduction
Additional context
I checked couple of files in this repo and it seems like
value
is implicitly typecasted to boolean, andnull
is falsy in a same wayundefined
is. Of course, some investigation is required, but it seems like an extremely easy fix.The text was updated successfully, but these errors were encountered: