Making your Angular 2 library statically analyzable for AoT
Isaac Mann
15933

Another one from the statically series:

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

Before:

// definition
const SELECTOR_1 = 'lib-component-a';
const SELECTOR_2 = 'lib-component-b';
export class LibSelectors {
static get SELECTOR_1() { return SELECTOR_1; }
static get SELECTOR_2() { return SELECTOR_2; }

/* other things */
}
// usage
@Component({
moduleId: `${module.id}`,
selector: LibSelectors.SELECTOR_1,
templateUrl: './component.html'
})
export class LibComponent1 {/* ... */}

After:

// definition
export const SELECTOR_1 = 'lib-component-a';
export const SELECTOR_2 = 'lib-component-b';
export class LibSelectors {
/* other things */
}
// usage
@Component({
moduleId: `${module.id}`,
selector: SELECTOR_1,
templateUrl: './component.html'
})
export class LibComponent1 {/* ... */}
One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.