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
Expected behavior:
The Array.isArray() type guard check should detect that record.message is a string. Note that if the message field is changed to string | string[] then everything works as expected. It's only when it's a ReadonlyArray<T> that it fails to compile. I can definitely add a as string cast, but that's kind of ugly and potentially dangerous if I change the data type later.
Actual behavior:
An error is reported: error TS2322: Type 'string | ReadonlyArray<string>' is not assignable to type 'string'.
The text was updated successfully, but these errors were encountered:
Automatically closing this issue for housekeeping purposes. The issue labels indicate that it is unactionable at the moment or has already been addressed.
TypeScript Version: 2.6.1
Code
Expected behavior:
The
Array.isArray()
type guard check should detect thatrecord.message
is a string. Note that if themessage
field is changed tostring | string[]
then everything works as expected. It's only when it's aReadonlyArray<T>
that it fails to compile. I can definitely add aas string
cast, but that's kind of ugly and potentially dangerous if I change the data type later.Actual behavior:
An error is reported:
error TS2322: Type 'string | ReadonlyArray<string>' is not assignable to type 'string'.
The text was updated successfully, but these errors were encountered: