error TS2322: Type 'string | string[]' is not assignable to type 'string'

Discussão em 'Angular' iniciado por awais nawaz, Novembro 19, 2024.

  1. awais nawaz

    awais nawaz Guest

    [​IMG]I have an @Input() property with the data type string | string[], before upgrading to angular 16 it was working fine but after I upgraded to Angular 16 I have been getting this error. I am not sure where I am wrong. I have a component which has input property like below. let call this MyComponent @Input() info: string | string[];

    somewhere in my app I am using this component and sending the info value.

    case1: <my-component [info]="value" value = 'something in ts file'

    case2: <my-component [info]="arrayValue"> arrayValue = ['a', 'b', 'c'];

    I am not sure what is wrong.

    I already tried making the type like below.

    export type stringOrArray = string | string[];

    but got the same error.

    Continue reading...

Compartilhe esta Página