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 started getting this error. I'm not sure where I went wrong. I have a component that has an input property as shown below:
let call this MyComponent
@Input() info: string | string[];
Somewhere in my app, I am using this component and passing the info
value:
// Case #1
// value = 'something in ts file'
<my-component [info]="value">
// Case #2
// arrayValue = ['a', 'b', 'c']
<my-component [info]="arrayValue">
I'm not sure what is wrong. I have already tried changing the type like this:
export type stringOrArray = string | string[];
However, I got the same error.
string
type. It can't accept thestring[]
value.info
consumed in the component? Is there an assignmentsth = someFunction(this.info)
, is it used in the template<some-child someInput="info">
?