fix(ivy): ngcc generates setClassMetadata calls for ES5 bundles (#27438)
ngcc would feed ngtsc with the function declaration inside of an IIFE as that is considered the class symbol's declaration node, according to TypeScript's `ts.Symbol.valueDeclaration`. ngtsc however only considered variable decls and actual class decls as potential class declarations, so given the function declaration node it would fail to generate the `setClassMetadata` call. ngtsc no longer makes its own assumptions about what classes look like, but always asks the reflection host to yield this kind of information. PR Close #27438
This commit is contained in:
@ -20,10 +20,7 @@ import {CtorParameter, Decorator, ReflectionHost} from '../../host';
|
||||
*/
|
||||
export function generateSetClassMetadataCall(
|
||||
clazz: ts.Declaration, reflection: ReflectionHost, isCore: boolean): Statement|null {
|
||||
// Classes come in two flavors, class declarations (ES2015) and variable declarations (ES5).
|
||||
// Both must have a declared name to have metadata set on them.
|
||||
if ((!ts.isClassDeclaration(clazz) && !ts.isVariableDeclaration(clazz)) ||
|
||||
clazz.name === undefined || !ts.isIdentifier(clazz.name)) {
|
||||
if (!reflection.isClass(clazz) || clazz.name === undefined || !ts.isIdentifier(clazz.name)) {
|
||||
return null;
|
||||
}
|
||||
const id = ts.updateIdentifier(clazz.name);
|
||||
|
Reference in New Issue
Block a user