Following is a Node.js API written in Typescript,
app.post('/photos/upload', upload.array('photos', 12), async (req, res) => {
var response = { }
var list = []
try {
const col = await loadCollection(COLLECTION_NAME, db)
var myfiles = req.files
console.log("myfiles", myfiles);
myfiles.map( function(item, index) {
//return checkExisting(col, item)
})
}}
and getting the following typescript error at the line myfiles.map(function(item, index) {
index.ts:77:13 - error TS2349: This expression is not callable.
Not all constituents of type 'File[] | (<U>(callbackfn: (value: File, index: number, array: File[]) => U, thisArg?: any) => U[])' are callable.
Type 'File[]' has no call signatures.
77 myfiles.map( function(item, index) {
~~~
As I am completely new to Typescript, not sure, what is the problem, myfiles.map(callback) is a valid callable method on an array so why typescript reports not callbale.
async (req: {files: any[]}, res)checkExistingdoes. Take a look at this. stackoverflow.com/a/51573837/17447checkExistingand tried but same error.checkExistinga functionconsole.logis not executed. I tried it. Moreover I see in the terminalnpm ERR! [email protected] prestart:tsc`` andFailed at the [email protected] prestart script.