This is the example code from my video about using async/await with Cloud Functions. I've placed it here in a gist so it's easier to compare the "before" and "after" states for each case.
The code in this project is licensed under the Apache License 2.0.
Copyright 2018 Google LLC
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
here is my error
src/index.ts:17:24 - error TS2532: Object is possibly 'undefined'.
17 const cities = areaSnapshot.data().cities
~~~~~~~~~~~~~~~~~~~
src/index.ts:18:15 - error TS7034: Variable 'promises' implicitly has type 'any[]' in some locations where its type cannot be determined.
18 const promises = []
~~~~~~~~
src/index.ts:19:24 - error TS7006: Parameter 'city' implicitly has an 'any' type.
19 cities.forEach(city => {
~~~~
src/index.ts:24:45 - error TS7005: Variable 'promises' implicitly has an 'any[]' type.
24 const snapshots = await Promise.all(promises)
~~~~~~~~
src/index.ts:26:15 - error TS7034: Variable 'results' implicitly has type 'any[]' in some locations where its type cannot be determined.
26 const results = []
~~~~~~~
src/index.ts:33:23 - error TS7005: Variable 'results' implicitly has an 'any[]' type.
33 response.send(results)
~~~~~~~
Found 6 errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! functions@ build:
tsc
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the functions@ build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.