angular 5应用程序中出现奇怪的构建时间错误

angular 5应用程序中出现奇怪的构建时间错误,angular,typescript,build,production,Angular,Typescript,Build,Production,我正在开发一个应用程序,从http请求中获取对象,并将其转换为可写入数组,如下所示。当我在开发模式下运行应用程序时,代码有时会运行,并给出如下随机错误。但是当我运行ng build-prod时,它总是给我以下错误,我因此陷入困境 我在哪里错过了什么 Object.keys(res['com'][element]['schema']['properties']).forEach(inputKey => { this.newfdata[elemen

我正在开发一个应用程序,从http请求中获取对象,并将其转换为可写入数组,如下所示。当我在开发模式下运行应用程序时,代码有时会运行,并给出如下随机错误。但是当我运行ng build-prod时,它总是给我以下错误,我因此陷入困境

我在哪里错过了什么

         Object.keys(res['com'][element]['schema']['properties']).forEach(inputKey => {
              this.newfdata[element]['properties'].push(res['com'][element]['schema']['properties'][inputKey]);

        }



       // this is line no. 223
                this.objectProps = Object.keys(res['com'][element]['schema']['properties']).map(prop => { 

          return Object.assign({}, { key: prop} , res['com'][element]['schema']['properties'][prop]);

        // this is line no. 228
          });
由于上面的行,我得到了下面的错误

ERROR in src/app/shared/layout/add.component.ts(223,5): error TS1005: ',' expected.
src/app/shared/layout/add.component.ts(228,11): error TS1005: ')' expected.
请帮帮我。由于这个问题,整个应用程序没有进入prod模式


提前谢谢

您在关闭输入键功能之前关闭了forEach,可能是这导致了错误,请更改第223行顶部的行,如下所示,希望这能解决问题

 Object.keys(res['com'][element]['schema']['properties']).forEach(inputKey => {
          this.newfdata[element]['properties'].push(res['com'][element]['schema']['properties'][inputKey]

    }); // close forEach 



   // this is line no. 223
            this.objectProps = Object.keys(res['com'][element]['schema']['properties']).map(prop => { 

      return Object.assign({}, { key: prop} , res['com'][element]['schema']['properties'][prop]);

    // this is line no. 228
      });

该错误可能是由于您以前编写的某些其他代码造成的。也许你有一个函数没有正确关闭?是的,这就是问题所在。谢谢你伸出援手。奇怪的是TS在开发模式中忽略了这一点。