fix(ngcc): render adjacent statements after static properties (#33630)
See https://github.com/angular/angular/pull/33337#issuecomment-545487737 Fixes FW-1664 PR Close #33630
This commit is contained in:

committed by
atscott

parent
7b87392f47
commit
fe12d0dc78
@ -35,4 +35,25 @@ export class Esm5RenderingFormatter extends EsmRenderingFormatter {
|
||||
const insertionPoint = returnStatement.getFullStart();
|
||||
output.appendLeft(insertionPoint, '\n' + definitions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the adjacent statements inside the IIFE of each decorated class
|
||||
*/
|
||||
addAdjacentStatements(output: MagicString, compiledClass: CompiledClass, statements: string):
|
||||
void {
|
||||
const iifeBody = getIifeBody(compiledClass.declaration);
|
||||
if (!iifeBody) {
|
||||
throw new Error(
|
||||
`Compiled class declaration is not inside an IIFE: ${compiledClass.name} in ${compiledClass.declaration.getSourceFile().fileName}`);
|
||||
}
|
||||
|
||||
const returnStatement = iifeBody.statements.find(ts.isReturnStatement);
|
||||
if (!returnStatement) {
|
||||
throw new Error(
|
||||
`Compiled class wrapper IIFE does not have a return statement: ${compiledClass.name} in ${compiledClass.declaration.getSourceFile().fileName}`);
|
||||
}
|
||||
|
||||
const insertionPoint = returnStatement.getFullStart();
|
||||
output.appendLeft(insertionPoint, '\n' + statements);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user