I have two interfaces which looks like this.
export interface TableBoxPropsHeader{
name: string,
isIconOnly: boolean
}
export interface TableBoxProps<T> {
headerNames: TableBoxPropsHeader[],
// some stuff
}
I am trying to create a variable with this definition, but for some reason it says I am trying to pass a string[]
array instead of a TableBoxPropsHeader[]
array.
private tableBoxProps: TableBoxProps<SomeType> = {
headerNames: [{name: "Name", isIconOnly:false}, {name: "Category", isIconOnly:true}],
I am using VSCode and it does not complain about the above. But the npm prints the following
Types of property 'headerNames' are incompatible.
Type 'string[]' is not assignable to type 'TableBoxPropsHeader[]'
Type 'string' is not assignable to type 'TableBoxPropsHeader'.
What am I doing wrong? How do I create an array of an interface?
Allright, this is somewhat stupid of me. There was another variable in a different file with the error. It works perfectly fine now...
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.