编译angular 5项目时打字稿中的随机错误

时间:2018-02-28 07:33:08

标签: angular typescript compiler-errors

我正在开展一个角度为5的项目,该项目有一个名为jform的组件。 当我做" ng serve"命令随机出现以下错误。意味着有时会来,有时候不会来。

        src/app/jform/jform.component.ts(178,2): error TS1005: ',' expected.
        src/app/jform/jform.component.ts(178,185): error TS1005: ')' expected.
        src/app/jform/jform.component.ts(207,18): error TS1005: ',' expected.

这是我的源代码,它给出了这个错误, 第8行:

                  import { TabsComponent } from '../tabs/tabs.component';

第178行:

            this.objectProps = Object.keys(res['com'][element]['schema']
            ['properties']).map(prop => { return Object.assign({}, 
             { key: prop} , res['com'][element]['schema']['properties'][prop]);});

第207行:

                  for(let prop of Object.keys(res['com']['schema']
               ['hidden_properties'])) {
                 formGroup[prop] = new FormControl(res['com']['schema']['hidden_properties'][prop].value || '', this.mapValidators(res['com']['schema']['hidden_properties'][prop].validation));
                    }

这是我正在使用的角度版本:

         Angular CLI: 1.7.1
         Node: 8.9.2 
         OS: win32 ia32
         Angular: 5.2.6

         @angular/cdk: 5.2.3
         @angular/cli: 1.7.1
         @angular/material: 5.2.3
         @angular-devkit/build-optimizer: 0.3.2
         @angular-devkit/core: 0.3.2
         @angular-devkit/schematics: 0.3.2
         @ngtools/json-schema: 1.2.0
         @ngtools/webpack: 1.10.1
         @schematics/angular: 0.3.2
         @schematics/package-update: 0.3.2
         typescript: 2.4.2 
         webpack: 3.11.0

是由于我的设置或代码中的概率?请帮助我。

更新:我使用的唯一解决方法是只添加空间或从jform.component.ts文件中删除空格并再次编译,错误就消失了。

1 个答案:

答案 0 :(得分:1)

我经常需要重新启动编译器,然后一切都会再次运行。

相关问题