I think I might have found a bug with the '@arcgis/core/rest/support/JobInfo' type definitions. When calling the fetchResultData() method as described in the documentation with the jobInfo constant typed as JobInfo, I get an error saying "An argument for 'resultName' was not provided." and the application won't compile. If I change the type to any it seems to work fine. The type definition seems to want to have jobId as the first argument and resultName for the second argument for the fetchResultData() method but adding the jobId made the application produce an error when run. Everything seems to work fine if I type my jobInfo constant to any and only include the single argument in the fetchResultData() method. Three code examples are below.
This one fails to compile with the "An argument for 'resultName' was not provided" error
// More above....
const jobInfo: JobInfo = await geoprocessor.submitJob(
this.geoprocessorUrl,
params,
geoprocessingOptions
)
const options = {
statusCallback: (jobInfo: JobInfo) => {
const timestamp = new Date().toLocaleTimeString()
const message = jobInfo.messages[jobInfo.messages.length - 1]
console.log(`${timestamp}: ${message.description}`)
},
}
await jobInfo.waitForJobCompletion(options)
const [directionsResult, routesResult, stopsResult] = await Promise.all([
jobInfo.fetchResultData('out_directions'),
jobInfo.fetchResultData('out_routes'),
jobInfo.fetchResultData('out_stops'),
])
// More lines below
This example which includes the jobId argument and makes the TypeScript compiler happy but errors out in the dev tools console with "ERROR Error: Uncaught (in promise): [request:server]: Unable to complete operation."
// More lines above
const jobInfo: JobInfo = await geoprocessor.submitJob(
this.geoprocessorUrl,
params,
geoprocessingOptions
)
const options = {
statusCallback: (jobInfo: JobInfo) => {
const timestamp = new Date().toLocaleTimeString()
const message = jobInfo.messages[jobInfo.messages.length - 1]
console.log(`${timestamp}: ${message.description}`)
},
}
await jobInfo.waitForJobCompletion(options)
const [directionsResult, routesResult, stopsResult] = await Promise.all([
jobInfo.fetchResultData(jobInfo.jobId, 'out_directions'),
jobInfo.fetchResultData(jobInfo.jobId, 'out_routes'),
jobInfo.fetchResultData(jobInfo.jobId, 'out_stops'),
])
// More lines below
Changing they type to any seems to fix the compiler error and the app seems to work fine.
// More lines above
const jobInfo: any = await geoprocessor.submitJob(
this.geoprocessorUrl,
params,
geoprocessingOptions
)
const options = {
statusCallback: (jobInfo: JobInfo) => {
const timestamp = new Date().toLocaleTimeString()
const message = jobInfo.messages[jobInfo.messages.length - 1]
console.log(`${timestamp}: ${message.description}`)
},
}
await jobInfo.waitForJobCompletion(options)
const [directionsResult, routesResult, stopsResult] = await Promise.all([
jobInfo.fetchResultData('out_directions'),
jobInfo.fetchResultData('out_routes'),
jobInfo.fetchResultData('out_stops'),
])
// More lines below
Is this truly a bug in the Type definitions or am I using the wrong type for my jobInfo constant? Using the any type seems to work but I hate using any 🙂
Solved! Go to Solution.
This should be fixed in the "next" release for 4.21
https://www.npmjs.com/package/@arcgis/core/v/4.21.0-next.20210831
And will be in the 4.21 release too. Can you try with "next" to verify? I was hesitant to do a 4.20 patch release just for typings, sorry.
This should be fixed in the "next" release for 4.21
https://www.npmjs.com/package/@arcgis/core/v/4.21.0-next.20210831
And will be in the 4.21 release too. Can you try with "next" to verify? I was hesitant to do a 4.20 patch release just for typings, sorry.
Thanks @ReneRubalcava !
Upgrading to "@arcgis/core": "^4.21.0-next.20210831" fixed the issue.