mutator.arrayAppend is not a function

Based on a old post of mine [Old Post] (Dynamic way ofSubDoc Operations)on how I can pass dynamically a list of multiple subdoc upserts to couchbase mutateIn function. Tried to make it work with JavaScript SDK 3.1.2 with no luck.

The errors i am getting are

TypeError: mutator.arrayAppend is not a function
UnhandledPromiseRejectionWarning: TypeError: Cannot read property ‘length’ of undefined
Not sure what I am missing here ?

Just as side node the code is written in typescript…

export interface IdocArray {
        path: string,
        doc: string
    }
    const multiUpsertSubDoc = async (collectId: string, id: string ,docArray: Array<IdocArray>) => {
        try {
            let couchCollect = collectionWithName(collectId)
            const mutator =  couchCollect.mutateIn(id)
            for(let i=0; i < docArray.length; i++){
                mutator.arrayAppend(docArray[i].path, docArray[i].doc )
            }
            let result = await mutator.execute()
            return {id, result}
        } catch (error) {
            if (error instanceof couchbase.DocumentExistsError) {
                console.log("Document does not Exists")
            }
            console.log(error)
            return {id, error}
        }
    }