fix(ivy): proper resolution of Enums in Component decorator (#27971)

Prior to this change Component decorator was resolving `encapsulation` value a bit incorrectly, which resulted in `encapsulation: NaN` in compiled code. Now we resolve the value as Enum memeber and throw if it's not the case. As a part of this update, the `changeDetection` field handling is also added, the resolution logic is the same as the one used for `encapsulation` field.

PR Close #27971
This commit is contained in:
Andrew Kushnir
2019-01-07 16:35:06 -08:00
parent 142553abc6
commit c5ab3e8fd2
7 changed files with 122 additions and 13 deletions

View File

@ -257,7 +257,8 @@ export class StaticInterpreter {
node.members.forEach(member => {
const name = this.stringNameFromPropertyName(member.name, context);
if (name !== undefined) {
map.set(name, new EnumValue(enumRef, name));
const resolved = member.initializer && this.visit(member.initializer, context);
map.set(name, new EnumValue(enumRef, name, resolved));
}
});
return map;

View File

@ -70,7 +70,9 @@ export interface ResolvedValueArray extends Array<ResolvedValue> {}
* Contains a `Reference` to the enumeration itself, and the name of the referenced member.
*/
export class EnumValue {
constructor(readonly enumRef: Reference<ts.EnumDeclaration>, readonly name: string) {}
constructor(
readonly enumRef: Reference<ts.EnumDeclaration>, readonly name: string,
readonly resolved: ResolvedValue) {}
}
/**