2017-12-31 139 views
7

-aotオプション(ng build -aot)でアプリを構築しようとしています。私はこれが呼び出す必要がデコレータで関数呼び出しがサポートされていません

ERROR in Error during template compile of 'MyComponent' 
    Function calls are not supported in decorators but 'classLogger' was called in 'cLog' 
    'cLog' calls 'classLogger'. 

と私は私はそれを動作させるために、コードを変更することが出来るのですかアイデアを持っていない:私は次のエラーを持っています。

export function classLogger(_classOptions?) { 
    const myLogger = new MyLogger(); 
    myLogger.options = Object.assign({}, defaultClassOptions, _classOptions); 

    return myLogger.loggerCB; 
} 

// export function clog(options = defaultClassOptions): Function { 
export function cLog(options?): Function { 
    return loggingEnabled ? classLogger(options) : emptyClassDecorator(); 
} 

P.S.クラスデコレータはデコレータパッチコールバックに転送する必要のあるオプションを取ります。

+0

は角/ CLI 1.6.8は、問題を解決し、@ ... – zhekaus

答えて

0

私もこの問題に遭遇しました。私の状況では、BusyConfigパラメータをオーバーライドしたいと思います。アプリケーションはng serveで正常に動作しますが、私は生産のためにアプリを構築したいときはFunction calls are not supported in decorators but ...例外が発生します。

私のソリューションは、以下の通りです:ng build --prod --aot

+0

あなたの解決策は何も解決していないように見えるよう ng build --prod --aot=false

The Angular Ahead-of-Time (AOT) compiler converts your Angular HTML and TypeScript code into efficient JavaScript code during the build phase before the browser downloads and runs that code.

ng build --prodが同じです。私は特にAOTを使いたいという問題に遭遇しました。 AOTは生産に不可欠です。 – zhekaus

関連する問題