fix(ngcc): override getInternalNameOfClass()
and getAdjacentNameOfClass()
for ES5 (#33533)
In ES5 the class consists of an outer variable declaration that is initialised by an IIFE. Inside the IIFE the class is implemented by an inner function declaration that is returned from the IIFE. This inner declaration may have a different name to the outer declaration. This commit overrides `getInternalNameOfClass()` and `getAdjacentNameOfClass()` in `Esm5ReflectionHost` with methods that can find the correct inner declaration name identifier. PR Close #33533
This commit is contained in:

committed by
atscott

parent
90f33dd11d
commit
93a23b9ae0
@ -2088,6 +2088,28 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('getInternalNameOfClass()', () => {
|
||||
it('should return the name of the class (there is no separate inner class in ES2015)', () => {
|
||||
loadTestFiles([SIMPLE_CLASS_FILE]);
|
||||
const {program} = makeTestBundleProgram(SIMPLE_CLASS_FILE.name);
|
||||
const host = new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
|
||||
const node =
|
||||
getDeclaration(program, SIMPLE_CLASS_FILE.name, 'EmptyClass', isNamedClassDeclaration);
|
||||
expect(host.getInternalNameOfClass(node).text).toEqual('EmptyClass');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getAdjacentNameOfClass()', () => {
|
||||
it('should return the name of the class (there is no separate inner class in ES2015)', () => {
|
||||
loadTestFiles([SIMPLE_CLASS_FILE]);
|
||||
const {program} = makeTestBundleProgram(SIMPLE_CLASS_FILE.name);
|
||||
const host = new Esm2015ReflectionHost(new MockLogger(), false, program.getTypeChecker());
|
||||
const node =
|
||||
getDeclaration(program, SIMPLE_CLASS_FILE.name, 'EmptyClass', isNamedClassDeclaration);
|
||||
expect(host.getAdjacentNameOfClass(node).text).toEqual('EmptyClass');
|
||||
});
|
||||
});
|
||||
|
||||
describe('getModuleWithProvidersFunctions()', () => {
|
||||
it('should find every exported function that returns an object that looks like a ModuleWithProviders object',
|
||||
() => {
|
||||
|
Reference in New Issue
Block a user