Closed
Description
TypeScript Version: 4.2.0-dev.20201208
Search Terms:
Code
interface IAction {
x: number;
}
function foo(arg: IAction | ReadonlyArray<IAction>) {
const actions: ReadonlyArray<IAction> = Array.isArray(arg) ? arg : [arg];
}
Expected behavior:
This compiles fine in TS 4.1.2
Actual behavior:
In the latest nightly, this produces this error:
Type '(IAction & any[]) | (readonly IAction[] & any[]) | (IAction | readonly IAction[])[]' is not assignable to type 'readonly IAction[]'.
Type '(IAction | readonly IAction[])[]' is not assignable to type 'readonly IAction[]'.
Type 'IAction | readonly IAction[]' is not assignable to type 'IAction'.
Property 'x' is missing in type 'readonly IAction[]' but required in type 'IAction'.ts(2322)
Related Issues: