'return value includes both array and object?

One of the functions I call from google firebase returns a response that looks the below.

I am not familiar with this syntax -- particularly the use of the '&' sign in the return value. It looks like it returns both an array and an object.

If I have an interface which matches the 'object' part of the response, what is the best way to retrieve just the object from the attribResponse return value and coerce it to an object of the interface type?

  attribResponse: [string, number, string, string, boolean, number] & {
    name: string;
    attribType: number;
    description: string;
    accessorMethod: string;
    isIndexed: boolean;
    paramType: number;
}


Solution 1:[1]

This intersection type can be treated as an object or as a tuple, depending on your preference.

If you have an interface representing the object part of the type, you should be able to assing the intersection type tou your interface

playground link

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lesiak