andreypopp/autobind-decorator

boundMethod decorator might not be usable in Angular production builds

Open

#82 opened on Dec 13, 2018

View on GitHub
 (5 comments) (1 reaction) (0 assignees)JavaScript (76 forks)batch import
help wanted

Repository metrics

Stars
 (1,446 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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.

Contributor guide