不支持函数调用

时间:2017-09-10 16:21:21

标签: angular angular-cli

我正在使用 @angular: 4.3.6 @angular/cdk: 2.0.0-beta.10 @angular/material: 2.0.0-beta.10 @angular/cli: "^1.4.1

每当我尝试ng serve时,我都会收到以下错误。

ERROR in Error: Error encountered resolving symbol values statically. 
Function calls are not supported. Consider replacing the function or lambda with a reference to an exported function (position 194:50 in the original .ts file), 
resolving symbol NgModule in d:/projects/webclient/node_modules/@angular/core/core.d.ts, 
resolving symbol CoreModule in d:/projects/webclient/src/core/core.module.ts, 
resolving symbol CoreModule in d:/projects/webclient/src/core/core.module.ts

我没有在CoreModule下面使用或导出任何lambda函数。

import { BrowserModule } from '@angular/platform-browser';
import { CommonModule } from '@angular/common';
import { NgModule, Inject } from '@angular/core';
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';

import { NgReduxModule, NgRedux } from '@angular-redux/store';
import { applyMiddleware, Store, combineReducers, compose, createStore } from 'redux';
import { createLogger } from 'redux-logger';

import { SharedModule } from 'shared/shared.module';

import { routes } from './core.routes';

import { STORE_PROVIDER, IAppState } from 'core/models/store';
import * as r from 'core/reducers';
import * as c from './components';
import * as v from './views';
import * as s from './services';
import { MenuAction, MenuGroup, MenuItem } from 'core/models';

@NgModule({
  imports: [
    BrowserModule,
    CommonModule,
    HttpModule,
    RouterModule.forRoot(routes),
    BrowserAnimationsModule,
    NgReduxModule,
    SharedModule
  ],
  declarations: [
    c.AppbarComponent,
    v.AppComponent,
    v.SettingsComponent
  ],
  providers: [
    { provide: STORE_PROVIDER, useValue: r.sidebar, multi: true },
    { provide: STORE_PROVIDER, useValue: r.actionbar, multi: true },
    { provide: STORE_PROVIDER, useValue: r.tabs, multi: true },
    s.ActionbarService,
    s.SidebarService,
    s.TabsService,
  ]
})
export class CoreModule {
  constructor( @Inject(STORE_PROVIDER) storeProviders: any[], ngRedux: NgRedux<{}>,
    actionbarService: s.ActionbarService, sidebarService: s.SidebarService) {
    ngRedux.configureStore(r.generateRootReducer(storeProviders), {}, [createLogger()]);
  }
}

1 个答案:

答案 0 :(得分:0)

所以问题是class Solution(object): def sumOfLeftLeaves(self,root): if root.val is None: return 0 elif root.left is None and root.right is not None: return self.sumOfLeftLeaves(root.right) elif root.left is not None and root.right is None: return self.sumOfLeftLeaves(root.left) elif root.left is not None and root.right is not None: if root.left.left is None and root.left.right is None: if (root.right.left is not None) or (root.right.right is not None): return root.left.val + self.sumOfLeftLeaves(root.right) else: return root.left.val else: return (self.sumOfLeftLeaves(root.left)+self.sumOfLeftLeaves(root.right)) else: return 0 配置错误。在我的主要模块中,我使用绝对路径导入tsconfig(即CoreModule而不是root/core/core.module)。基本上我错过了../core/core.module文件中的baseUrl

我不明白为什么会出现这种情况有两个原因(如果有人可以向我解释,请理解):

  1. 这不是一个新项目,而是以前的工作。
  2. tsconfig.app.json从主tsconfig.app.json文件扩展而来,该文件已在其中设置了正确的tsconfig.json
  3. 无论如何,我希望这有助于其他有同样问题的人。