I've been grappling with this problem to no avail. Despite poring over various articles on downlevelIteration and target, and making adjustments to both tsconfig.json and package.json, I still keep encountering the same pesky error message.
Here's a snippet from my tsconfig.json:
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
// NZ 2022-09-09
"downlevelIteration": true,
"lib": ["DOM","ES6","ES2015.Collection","ES2015.Iterable"],
//--------------
"outDir": "dist",
"rootDir": ".",
"sourceMap": true,
"strict": false,
"composite": true
}
}
Here's a snippet of the source code defining the Map structure:
interface outBrk {
title: string;
subTitle: string;
...
type fldName = string;
const fields = new Map<fldName, keyof outBrk>([
['Title', 'title'],
['Sub-title', 'sub_title'],
...
The code snippet triggering the error message is:
for (const [xlsxKey, jsonKey] of fields) {
if (jsonKey) {
if (jsonKey === 'vlnlist') {
...
Here's the error message I'm encountering:
error TS2802: Type 'Map<string, keyof outBrk>' can only be iterated through when using the '--downlevelIteration' flag or with a '--target' of 'es2015' or higher.
248 for (const [xlsxKey, jsonKey] of fields) {
~~~~~~
I'm seeking guidance on how to tackle this issue effectively. Thank you in advance.