andreypopp/autobind-decorator

boundMethod decorator might not be usable in Angular production builds

Open

#82 建立於 2018年12月13日

在 GitHub 查看
 (5 留言) (1 反應) (0 負責人)JavaScript (1,446 star) (76 fork)batch import
help wanted

描述

I get this error when running production builds of my Angular app, which contains usages of the boundMethod decorator:

 Error encountered resolving symbol values statically. Only initialized variables and constants can be referenced because the value of this variable is needed by the template compiler (position 3:22 in the original .ts file), resolving symbol boundMethod in C:/Users/Jeff/[path to my app]/node_modules/autobind-decorator/index.d.ts

I believe it is the Angular AoT compiler which is throwing this error. Devleopment builds, which don't use AoT, don't produce these errors.

I import the decorator using import { boundMethod } from "autobind-decorator";

A workaround is to use the autobind decorator instead, though that is discouraged by this package's docs.

貢獻者指南