style(ngcc): reformat of ngcc after clang update (#36447)
PR Close #36447
This commit is contained in:

committed by
Kara Erickson

parent
bfa55162de
commit
74b7a8eaf5
@ -6,7 +6,7 @@
|
||||
* found in the LICENSE file at https://angular.io/license
|
||||
*/
|
||||
import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system';
|
||||
import {TestFile, runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {runInEachFileSystem, TestFile} from '../../../src/ngtsc/file_system/testing';
|
||||
import {isNamedVariableDeclaration} from '../../../src/ngtsc/reflection';
|
||||
import {getDeclaration} from '../../../src/ngtsc/testing';
|
||||
import {loadFakeCore, loadTestFiles} from '../../../test/helpers';
|
||||
@ -90,15 +90,15 @@ exports.AliasedDirective$1 = AliasedDirective$1;
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, TOPLEVEL_DECORATORS_FILE.name, 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('core.Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('core.Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -111,15 +111,15 @@ exports.AliasedDirective$1 = AliasedDirective$1;
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, TOPLEVEL_DECORATORS_FILE.name, 'AliasedDirective$1',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('core.Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('core.Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
|
@ -9,7 +9,7 @@
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {absoluteFrom, getFileSystem, getSourceFileOrError} from '../../../src/ngtsc/file_system';
|
||||
import {TestFile, runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {runInEachFileSystem, TestFile} from '../../../src/ngtsc/file_system/testing';
|
||||
import {ClassMemberKind, Import, isNamedVariableDeclaration} from '../../../src/ngtsc/reflection';
|
||||
import {getDeclaration} from '../../../src/ngtsc/testing';
|
||||
import {loadFakeCore, loadTestFiles, loadTsLib} from '../../../test/helpers';
|
||||
@ -168,16 +168,16 @@ runInEachFileSystem(() => {
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -189,16 +189,16 @@ runInEachFileSystem(() => {
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -210,16 +210,16 @@ runInEachFileSystem(() => {
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: './directives'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -234,15 +234,15 @@ runInEachFileSystem(() => {
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const input1 = members.find(member => member.name === 'input1') !;
|
||||
const input1 = members.find(member => member.name === 'input1')!;
|
||||
expect(input1.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input1.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
|
||||
const input2 = members.find(member => member.name === 'input2') !;
|
||||
const input2 = members.find(member => member.name === 'input2')!;
|
||||
expect(input2.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input2.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
});
|
||||
|
||||
it('should find decorated members on a class when mixing `ctorParameters` and `__decorate`',
|
||||
@ -254,10 +254,10 @@ runInEachFileSystem(() => {
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const input1 = members.find(member => member.name === 'input1') !;
|
||||
const input1 = members.find(member => member.name === 'input1')!;
|
||||
expect(input1.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input1.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
});
|
||||
|
||||
it('should find non decorated properties on a class', () => {
|
||||
@ -268,11 +268,11 @@ runInEachFileSystem(() => {
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const instanceProperty = members.find(member => member.name === 'instanceProperty') !;
|
||||
const instanceProperty = members.find(member => member.name === 'instanceProperty')!;
|
||||
expect(instanceProperty.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(instanceProperty.isStatic).toEqual(false);
|
||||
expect(ts.isBinaryExpression(instanceProperty.implementation !)).toEqual(true);
|
||||
expect(instanceProperty.value !.getText()).toEqual(`'instance'`);
|
||||
expect(ts.isBinaryExpression(instanceProperty.implementation!)).toEqual(true);
|
||||
expect(instanceProperty.value!.getText()).toEqual(`'instance'`);
|
||||
});
|
||||
|
||||
it('should find static methods on a class', () => {
|
||||
@ -283,10 +283,10 @@ runInEachFileSystem(() => {
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const staticMethod = members.find(member => member.name === 'staticMethod') !;
|
||||
const staticMethod = members.find(member => member.name === 'staticMethod')!;
|
||||
expect(staticMethod.kind).toEqual(ClassMemberKind.Method);
|
||||
expect(staticMethod.isStatic).toEqual(true);
|
||||
expect(ts.isMethodDeclaration(staticMethod.implementation !)).toEqual(true);
|
||||
expect(ts.isMethodDeclaration(staticMethod.implementation!)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should find static properties on a class', () => {
|
||||
@ -297,11 +297,11 @@ runInEachFileSystem(() => {
|
||||
isNamedVariableDeclaration);
|
||||
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
const staticProperty = members.find(member => member.name === 'staticProperty') !;
|
||||
const staticProperty = members.find(member => member.name === 'staticProperty')!;
|
||||
expect(staticProperty.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(staticProperty.isStatic).toEqual(true);
|
||||
expect(ts.isPropertyAccessExpression(staticProperty.implementation !)).toEqual(true);
|
||||
expect(staticProperty.value !.getText()).toEqual(`'static'`);
|
||||
expect(ts.isPropertyAccessExpression(staticProperty.implementation!)).toEqual(true);
|
||||
expect(staticProperty.value!.getText()).toEqual(`'static'`);
|
||||
});
|
||||
|
||||
it('should find static properties on a class that has an intermediate variable assignment',
|
||||
@ -313,11 +313,11 @@ runInEachFileSystem(() => {
|
||||
isNamedVariableDeclaration);
|
||||
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
const staticProperty = members.find(member => member.name === 'staticProperty') !;
|
||||
const staticProperty = members.find(member => member.name === 'staticProperty')!;
|
||||
expect(staticProperty.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(staticProperty.isStatic).toEqual(true);
|
||||
expect(ts.isPropertyAccessExpression(staticProperty.implementation !)).toEqual(true);
|
||||
expect(staticProperty.value !.getText()).toEqual(`'static'`);
|
||||
expect(ts.isPropertyAccessExpression(staticProperty.implementation!)).toEqual(true);
|
||||
expect(staticProperty.value!.getText()).toEqual(`'static'`);
|
||||
});
|
||||
|
||||
it('should support decorators being used inside @angular/core', () => {
|
||||
@ -329,10 +329,10 @@ runInEachFileSystem(() => {
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const input1 = members.find(member => member.name === 'input1') !;
|
||||
const input1 = members.find(member => member.name === 'input1')!;
|
||||
expect(input1.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input1.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
});
|
||||
});
|
||||
|
||||
@ -346,10 +346,10 @@ runInEachFileSystem(() => {
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
|
||||
expect(parameters).toBeDefined();
|
||||
expect(parameters !.map(parameter => parameter.name)).toEqual([
|
||||
expect(parameters!.map(parameter => parameter.name)).toEqual([
|
||||
'_viewContainer', '_template', 'injected'
|
||||
]);
|
||||
expectTypeValueReferencesForParameters(parameters !, [
|
||||
expectTypeValueReferencesForParameters(parameters!, [
|
||||
'ViewContainerRef',
|
||||
'TemplateRef',
|
||||
'String',
|
||||
@ -366,20 +366,20 @@ runInEachFileSystem(() => {
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
|
||||
expect(parameters).toBeDefined();
|
||||
expect(parameters !.map(parameter => parameter.name)).toEqual([
|
||||
expect(parameters!.map(parameter => parameter.name)).toEqual([
|
||||
'_viewContainer', '_template', 'injected'
|
||||
]);
|
||||
expectTypeValueReferencesForParameters(parameters !, [
|
||||
expectTypeValueReferencesForParameters(parameters!, [
|
||||
'ViewContainerRef',
|
||||
'TemplateRef',
|
||||
null,
|
||||
]);
|
||||
|
||||
const decorators = parameters ![2].decorators !;
|
||||
const decorators = parameters![2].decorators!;
|
||||
expect(decorators.length).toEqual(1);
|
||||
expect(decorators[0].name).toBe('Inject');
|
||||
expect(decorators[0].import !.from).toBe('@angular/core');
|
||||
expect(decorators[0].import !.name).toBe('Inject');
|
||||
expect(decorators[0].import!.from).toBe('@angular/core');
|
||||
expect(decorators[0].import!.name).toBe('Inject');
|
||||
});
|
||||
});
|
||||
|
||||
@ -390,8 +390,8 @@ runInEachFileSystem(() => {
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const ctrDecorators = host.getConstructorParameters(classNode) !;
|
||||
const identifierOfViewContainerRef = (ctrDecorators[0].typeValueReference !as{
|
||||
const ctrDecorators = host.getConstructorParameters(classNode)!;
|
||||
const identifierOfViewContainerRef = (ctrDecorators[0].typeValueReference! as {
|
||||
local: true,
|
||||
expression: ts.Identifier,
|
||||
defaultImportStatement: null,
|
||||
@ -401,8 +401,8 @@ runInEachFileSystem(() => {
|
||||
bundle.program, _('/some_directive.js'), 'ViewContainerRef', ts.isClassDeclaration);
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfViewContainerRef);
|
||||
expect(actualDeclaration).not.toBe(null);
|
||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration !.viaModule).toBe(null);
|
||||
expect(actualDeclaration!.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration!.viaModule).toBe(null);
|
||||
});
|
||||
|
||||
it('should return the declaration of an externally defined identifier', () => {
|
||||
@ -411,8 +411,8 @@ runInEachFileSystem(() => {
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const classDecorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decoratorNode = classDecorators[0].node !;
|
||||
const classDecorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
const decoratorNode = classDecorators[0].node!;
|
||||
const identifierOfDirective =
|
||||
ts.isCallExpression(decoratorNode) && ts.isIdentifier(decoratorNode.expression) ?
|
||||
decoratorNode.expression :
|
||||
@ -421,10 +421,10 @@ runInEachFileSystem(() => {
|
||||
const expectedDeclarationNode = getDeclaration(
|
||||
bundle.program, _('/node_modules/@angular/core/index.d.ts'), 'Directive',
|
||||
isNamedVariableDeclaration);
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective!);
|
||||
expect(actualDeclaration).not.toBe(null);
|
||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration !.viaModule).toBe('@angular/core');
|
||||
expect(actualDeclaration!.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration!.viaModule).toBe('@angular/core');
|
||||
});
|
||||
});
|
||||
|
||||
@ -435,13 +435,13 @@ runInEachFileSystem(() => {
|
||||
const ngModuleRef = findVariableDeclaration(
|
||||
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'HttpClientXsrfModule_1');
|
||||
|
||||
const value = host.getVariableValue(ngModuleRef !);
|
||||
const value = host.getVariableValue(ngModuleRef!);
|
||||
expect(value).not.toBe(null);
|
||||
if (!value || !ts.isClassExpression(value)) {
|
||||
throw new Error(
|
||||
`Expected value to be a class expression: ${value && value.getText()}.`);
|
||||
}
|
||||
expect(value.name !.text).toBe('HttpClientXsrfModule');
|
||||
expect(value.name!.text).toBe('HttpClientXsrfModule');
|
||||
});
|
||||
|
||||
it('should return null if the variable has no assignment', () => {
|
||||
@ -449,7 +449,7 @@ runInEachFileSystem(() => {
|
||||
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
|
||||
const missingValue = findVariableDeclaration(
|
||||
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'missingValue');
|
||||
const value = host.getVariableValue(missingValue !);
|
||||
const value = host.getVariableValue(missingValue!);
|
||||
expect(value).toBe(null);
|
||||
});
|
||||
|
||||
@ -458,7 +458,7 @@ runInEachFileSystem(() => {
|
||||
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
|
||||
const nonDecoratedVar = findVariableDeclaration(
|
||||
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'nonDecoratedVar');
|
||||
const value = host.getVariableValue(nonDecoratedVar !);
|
||||
const value = host.getVariableValue(nonDecoratedVar!);
|
||||
expect(value).toBe(null);
|
||||
});
|
||||
});
|
||||
@ -468,7 +468,7 @@ runInEachFileSystem(() => {
|
||||
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
|
||||
const host = new Esm2015ReflectionHost(new MockLogger(), false, bundle);
|
||||
const classSymbol =
|
||||
host.findClassSymbols(bundle.program.getSourceFile(_('/ngmodule.js')) !)[0];
|
||||
host.findClassSymbols(bundle.program.getSourceFile(_('/ngmodule.js'))!)[0];
|
||||
const endOfClass = host.getEndOfClass(classSymbol);
|
||||
expect(endOfClass.getText())
|
||||
.toMatch(
|
||||
@ -479,7 +479,7 @@ runInEachFileSystem(() => {
|
||||
});
|
||||
|
||||
function findVariableDeclaration(
|
||||
node: ts.Node | undefined, variableName: string): ts.VariableDeclaration|undefined {
|
||||
node: ts.Node|undefined, variableName: string): ts.VariableDeclaration|undefined {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@
|
||||
import * as ts from 'typescript';
|
||||
|
||||
import {absoluteFrom, getFileSystem, getSourceFileOrError} from '../../../src/ngtsc/file_system';
|
||||
import {TestFile, runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {runInEachFileSystem, TestFile} from '../../../src/ngtsc/file_system/testing';
|
||||
import {ClassMemberKind, isNamedFunctionDeclaration, isNamedVariableDeclaration} from '../../../src/ngtsc/reflection';
|
||||
import {getDeclaration} from '../../../src/ngtsc/testing';
|
||||
import {loadFakeCore, loadTestFiles, loadTsLib} from '../../../test/helpers';
|
||||
@ -227,19 +227,18 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
it('should find the decorators on a minified class', () => {
|
||||
@ -248,19 +247,18 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_minified_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
|
||||
});
|
||||
|
||||
it('should find the decorators on an aliased class', () => {
|
||||
@ -269,16 +267,16 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_aliased_directive.js'), 'AliasedDirective$1',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -290,16 +288,16 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive_ctor_parameters.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -311,16 +309,16 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/node_modules/@angular/core/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: './directives'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -333,13 +331,12 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_minified_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const innerNode =
|
||||
getIifeBody(classNode) !.statements.find(isNamedFunctionDeclaration) !;
|
||||
const innerNode = getIifeBody(classNode)!.statements.find(isNamedFunctionDeclaration)!;
|
||||
const classSymbol = host.getClassSymbol(classNode);
|
||||
|
||||
expect(classSymbol).toBeDefined();
|
||||
expect(classSymbol !.declaration.valueDeclaration).toBe(classNode);
|
||||
expect(classSymbol !.implementation.valueDeclaration).toBe(innerNode);
|
||||
expect(classSymbol!.declaration.valueDeclaration).toBe(classNode);
|
||||
expect(classSymbol!.implementation.valueDeclaration).toBe(innerNode);
|
||||
});
|
||||
});
|
||||
|
||||
@ -352,15 +349,15 @@ export { AliasedDirective$1 };
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const input1 = members.find(member => member.name === 'input1') !;
|
||||
const input1 = members.find(member => member.name === 'input1')!;
|
||||
expect(input1.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input1.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
|
||||
const input2 = members.find(member => member.name === 'input2') !;
|
||||
const input2 = members.find(member => member.name === 'input2')!;
|
||||
expect(input2.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input2.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
});
|
||||
|
||||
it('should find decorated members on a class when mixing `ctorParameters` and `__decorate`',
|
||||
@ -372,10 +369,10 @@ export { AliasedDirective$1 };
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const input1 = members.find(member => member.name === 'input1') !;
|
||||
const input1 = members.find(member => member.name === 'input1')!;
|
||||
expect(input1.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input1.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
});
|
||||
|
||||
it('should find non decorated properties on a class', () => {
|
||||
@ -386,11 +383,11 @@ export { AliasedDirective$1 };
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const instanceProperty = members.find(member => member.name === 'instanceProperty') !;
|
||||
const instanceProperty = members.find(member => member.name === 'instanceProperty')!;
|
||||
expect(instanceProperty.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(instanceProperty.isStatic).toEqual(false);
|
||||
expect(ts.isBinaryExpression(instanceProperty.implementation !)).toEqual(true);
|
||||
expect(instanceProperty.value !.getText()).toEqual(`'instance'`);
|
||||
expect(ts.isBinaryExpression(instanceProperty.implementation!)).toEqual(true);
|
||||
expect(instanceProperty.value!.getText()).toEqual(`'instance'`);
|
||||
});
|
||||
|
||||
it('should find static methods on a class', () => {
|
||||
@ -401,10 +398,10 @@ export { AliasedDirective$1 };
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const staticMethod = members.find(member => member.name === 'staticMethod') !;
|
||||
const staticMethod = members.find(member => member.name === 'staticMethod')!;
|
||||
expect(staticMethod.kind).toEqual(ClassMemberKind.Method);
|
||||
expect(staticMethod.isStatic).toEqual(true);
|
||||
expect(ts.isFunctionExpression(staticMethod.implementation !)).toEqual(true);
|
||||
expect(ts.isFunctionExpression(staticMethod.implementation!)).toEqual(true);
|
||||
});
|
||||
|
||||
it('should find static properties on a class', () => {
|
||||
@ -415,11 +412,11 @@ export { AliasedDirective$1 };
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const staticProperty = members.find(member => member.name === 'staticProperty') !;
|
||||
const staticProperty = members.find(member => member.name === 'staticProperty')!;
|
||||
expect(staticProperty.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(staticProperty.isStatic).toEqual(true);
|
||||
expect(ts.isPropertyAccessExpression(staticProperty.implementation !)).toEqual(true);
|
||||
expect(staticProperty.value !.getText()).toEqual(`'static'`);
|
||||
expect(ts.isPropertyAccessExpression(staticProperty.implementation!)).toEqual(true);
|
||||
expect(staticProperty.value!.getText()).toEqual(`'static'`);
|
||||
});
|
||||
|
||||
it('should support decorators being used inside @angular/core', () => {
|
||||
@ -431,10 +428,10 @@ export { AliasedDirective$1 };
|
||||
isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const input1 = members.find(member => member.name === 'input1') !;
|
||||
const input1 = members.find(member => member.name === 'input1')!;
|
||||
expect(input1.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input1.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
});
|
||||
});
|
||||
describe('getConstructorParameters', () => {
|
||||
@ -447,10 +444,10 @@ export { AliasedDirective$1 };
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
|
||||
expect(parameters).toBeDefined();
|
||||
expect(parameters !.map(parameter => parameter.name)).toEqual([
|
||||
expect(parameters!.map(parameter => parameter.name)).toEqual([
|
||||
'_viewContainer', '_template', 'injected'
|
||||
]);
|
||||
expectTypeValueReferencesForParameters(parameters !, [
|
||||
expectTypeValueReferencesForParameters(parameters!, [
|
||||
'ViewContainerRef',
|
||||
'TemplateRef',
|
||||
'String',
|
||||
@ -467,10 +464,10 @@ export { AliasedDirective$1 };
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
|
||||
expect(parameters).toBeDefined();
|
||||
expect(parameters !.map(parameter => parameter.name)).toEqual([
|
||||
expect(parameters!.map(parameter => parameter.name)).toEqual([
|
||||
'_viewContainer', '_template', 'injected'
|
||||
]);
|
||||
expectTypeValueReferencesForParameters(parameters !, [
|
||||
expectTypeValueReferencesForParameters(parameters!, [
|
||||
'ViewContainerRef',
|
||||
'TemplateRef',
|
||||
null,
|
||||
@ -485,7 +482,7 @@ export { AliasedDirective$1 };
|
||||
bundle.program, _('/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
const decorators = parameters ![2].decorators !;
|
||||
const decorators = parameters![2].decorators!;
|
||||
|
||||
expect(decorators.length).toEqual(1);
|
||||
expect(decorators[0].import).toEqual({name: 'Inject', from: '@angular/core'});
|
||||
@ -522,7 +519,7 @@ export { AliasedDirective$1 };
|
||||
const ngModuleDecorators = ngModuleClasses.map(s => host.getDecoratorsOfSymbol(s));
|
||||
|
||||
expect(ngModuleClasses.length).toEqual(1);
|
||||
expect(ngModuleDecorators[0] !.map(d => d.name)).toEqual(['NgModule']);
|
||||
expect(ngModuleDecorators[0]!.map(d => d.name)).toEqual(['NgModule']);
|
||||
|
||||
const someDirectiveFile = getSourceFileOrError(bundle.program, _('/some_directive.js'));
|
||||
const someDirectiveClasses = host.findClassSymbols(someDirectiveFile);
|
||||
@ -532,7 +529,7 @@ export { AliasedDirective$1 };
|
||||
expect(someDirectiveDecorators.length).toEqual(3);
|
||||
expect(someDirectiveDecorators[0]).toBe(null);
|
||||
expect(someDirectiveDecorators[1]).toBe(null);
|
||||
expect(someDirectiveDecorators[2] !.map(d => d.name)).toEqual(['Directive']);
|
||||
expect(someDirectiveDecorators[2]!.map(d => d.name)).toEqual(['Directive']);
|
||||
});
|
||||
});
|
||||
|
||||
@ -543,8 +540,8 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const ctrDecorators = host.getConstructorParameters(classNode) !;
|
||||
const identifierOfViewContainerRef = (ctrDecorators[0].typeValueReference !as{
|
||||
const ctrDecorators = host.getConstructorParameters(classNode)!;
|
||||
const identifierOfViewContainerRef = (ctrDecorators[0].typeValueReference! as {
|
||||
local: true,
|
||||
expression: ts.Identifier,
|
||||
defaultImportStatement: null,
|
||||
@ -555,8 +552,8 @@ export { AliasedDirective$1 };
|
||||
isNamedVariableDeclaration);
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfViewContainerRef);
|
||||
expect(actualDeclaration).not.toBe(null);
|
||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration !.viaModule).toBe(null);
|
||||
expect(actualDeclaration!.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration!.viaModule).toBe(null);
|
||||
});
|
||||
|
||||
it('should return the declaration of an externally defined identifier', () => {
|
||||
@ -565,8 +562,8 @@ export { AliasedDirective$1 };
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, _('/some_directive.js'), 'SomeDirective',
|
||||
isNamedVariableDeclaration);
|
||||
const classDecorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decoratorNode = classDecorators[0].node !;
|
||||
const classDecorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
const decoratorNode = classDecorators[0].node!;
|
||||
|
||||
const identifierOfDirective =
|
||||
ts.isCallExpression(decoratorNode) && ts.isIdentifier(decoratorNode.expression) ?
|
||||
@ -576,10 +573,10 @@ export { AliasedDirective$1 };
|
||||
const expectedDeclarationNode = getDeclaration(
|
||||
bundle.program, _('/node_modules/@angular/core/index.d.ts'), 'Directive',
|
||||
isNamedVariableDeclaration);
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective !);
|
||||
const actualDeclaration = host.getDeclarationOfIdentifier(identifierOfDirective!);
|
||||
expect(actualDeclaration).not.toBe(null);
|
||||
expect(actualDeclaration !.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration !.viaModule).toBe('@angular/core');
|
||||
expect(actualDeclaration!.node).toBe(expectedDeclarationNode);
|
||||
expect(actualDeclaration!.viaModule).toBe('@angular/core');
|
||||
});
|
||||
|
||||
it('should find the "actual" declaration of an aliased variable identifier', () => {
|
||||
@ -589,9 +586,9 @@ export { AliasedDirective$1 };
|
||||
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'HttpClientXsrfModule_1',
|
||||
isNgModulePropertyAssignment);
|
||||
|
||||
const declaration = host.getDeclarationOfIdentifier(ngModuleRef !);
|
||||
const declaration = host.getDeclarationOfIdentifier(ngModuleRef!);
|
||||
expect(declaration).not.toBe(null);
|
||||
expect(declaration !.node !.getText()).toContain('function HttpClientXsrfModule()');
|
||||
expect(declaration!.node!.getText()).toContain('function HttpClientXsrfModule()');
|
||||
});
|
||||
});
|
||||
describe('getVariableValue', () => {
|
||||
@ -601,7 +598,7 @@ export { AliasedDirective$1 };
|
||||
const ngModuleRef = findVariableDeclaration(
|
||||
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'HttpClientXsrfModule_1');
|
||||
|
||||
const value = host.getVariableValue(ngModuleRef !);
|
||||
const value = host.getVariableValue(ngModuleRef!);
|
||||
expect(value).not.toBe(null);
|
||||
if (!value || !ts.isFunctionDeclaration(value.parent)) {
|
||||
throw new Error(
|
||||
@ -615,7 +612,7 @@ export { AliasedDirective$1 };
|
||||
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
|
||||
const missingValue = findVariableDeclaration(
|
||||
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'missingValue');
|
||||
const value = host.getVariableValue(missingValue !);
|
||||
const value = host.getVariableValue(missingValue!);
|
||||
expect(value).toBe(null);
|
||||
});
|
||||
|
||||
@ -624,7 +621,7 @@ export { AliasedDirective$1 };
|
||||
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
|
||||
const nonDecoratedVar = findVariableDeclaration(
|
||||
getSourceFileOrError(bundle.program, _('/ngmodule.js')), 'nonDecoratedVar');
|
||||
const value = host.getVariableValue(nonDecoratedVar !);
|
||||
const value = host.getVariableValue(nonDecoratedVar!);
|
||||
expect(value).toBe(null);
|
||||
});
|
||||
});
|
||||
@ -634,7 +631,7 @@ export { AliasedDirective$1 };
|
||||
const bundle = makeTestBundleProgram(_('/ngmodule.js'));
|
||||
const host = new Esm5ReflectionHost(new MockLogger(), false, bundle);
|
||||
const classSymbol =
|
||||
host.findClassSymbols(bundle.program.getSourceFile(_('/ngmodule.js')) !)[0];
|
||||
host.findClassSymbols(bundle.program.getSourceFile(_('/ngmodule.js'))!)[0];
|
||||
const endOfClass = host.getEndOfClass(classSymbol);
|
||||
expect(endOfClass.getText())
|
||||
.toMatch(
|
||||
@ -644,7 +641,7 @@ export { AliasedDirective$1 };
|
||||
});
|
||||
|
||||
function findVariableDeclaration(
|
||||
node: ts.Node | undefined, variableName: string): ts.VariableDeclaration|undefined {
|
||||
node: ts.Node|undefined, variableName: string): ts.VariableDeclaration|undefined {
|
||||
if (!node) {
|
||||
return;
|
||||
}
|
||||
@ -656,7 +653,7 @@ export { AliasedDirective$1 };
|
||||
});
|
||||
|
||||
function findIdentifier(
|
||||
node: ts.Node | undefined, identifierName: string,
|
||||
node: ts.Node|undefined, identifierName: string,
|
||||
requireFn: (node: ts.Identifier) => boolean): ts.Identifier|undefined {
|
||||
if (!node) {
|
||||
return undefined;
|
||||
|
@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import {absoluteFrom} from '../../../src/ngtsc/file_system';
|
||||
import {TestFile, runInEachFileSystem} from '../../../src/ngtsc/file_system/testing';
|
||||
import {runInEachFileSystem, TestFile} from '../../../src/ngtsc/file_system/testing';
|
||||
import {ClassMemberKind, isNamedVariableDeclaration} from '../../../src/ngtsc/reflection';
|
||||
import {getDeclaration} from '../../../src/ngtsc/testing';
|
||||
import {loadTestFiles} from '../../../test/helpers';
|
||||
@ -81,16 +81,16 @@ runInEachFileSystem(() => {
|
||||
const host = new UmdReflectionHost(new MockLogger(), false, bundle);
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('core.Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('core.Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -102,16 +102,16 @@ runInEachFileSystem(() => {
|
||||
const classNode = getDeclaration(
|
||||
bundle.program, SOME_DIRECTIVE_FILE.name, 'AliasedDirective$1',
|
||||
isNamedVariableDeclaration);
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode) !;
|
||||
const decorators = host.getDecoratorsOfDeclaration(classNode)!;
|
||||
|
||||
expect(decorators).toBeDefined();
|
||||
expect(decorators.length).toEqual(1);
|
||||
|
||||
const decorator = decorators[0];
|
||||
expect(decorator.name).toEqual('Directive');
|
||||
expect(decorator.identifier !.getText()).toEqual('core.Directive');
|
||||
expect(decorator.identifier!.getText()).toEqual('core.Directive');
|
||||
expect(decorator.import).toEqual({name: 'Directive', from: '@angular/core'});
|
||||
expect(decorator.args !.map(arg => arg.getText())).toEqual([
|
||||
expect(decorator.args!.map(arg => arg.getText())).toEqual([
|
||||
'{ selector: \'[someDirective]\' }',
|
||||
]);
|
||||
});
|
||||
@ -126,15 +126,15 @@ runInEachFileSystem(() => {
|
||||
bundle.program, SOME_DIRECTIVE_FILE.name, 'SomeDirective', isNamedVariableDeclaration);
|
||||
const members = host.getMembersOfClass(classNode);
|
||||
|
||||
const input1 = members.find(member => member.name === 'input1') !;
|
||||
const input1 = members.find(member => member.name === 'input1')!;
|
||||
expect(input1.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input1.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
|
||||
const input2 = members.find(member => member.name === 'input2') !;
|
||||
const input2 = members.find(member => member.name === 'input2')!;
|
||||
expect(input2.kind).toEqual(ClassMemberKind.Property);
|
||||
expect(input2.isStatic).toEqual(false);
|
||||
expect(input1.decorators !.map(d => d.name)).toEqual(['Input']);
|
||||
expect(input1.decorators!.map(d => d.name)).toEqual(['Input']);
|
||||
});
|
||||
|
||||
describe('getConstructorParameters', () => {
|
||||
@ -148,10 +148,10 @@ runInEachFileSystem(() => {
|
||||
const parameters = host.getConstructorParameters(classNode);
|
||||
|
||||
expect(parameters).toBeDefined();
|
||||
expect(parameters !.map(parameter => parameter.name)).toEqual([
|
||||
expect(parameters!.map(parameter => parameter.name)).toEqual([
|
||||
'_viewContainer', '_template', 'injected'
|
||||
]);
|
||||
expectTypeValueReferencesForParameters(parameters !, [
|
||||
expectTypeValueReferencesForParameters(parameters!, [
|
||||
'ViewContainerRef',
|
||||
'TemplateRef',
|
||||
null,
|
||||
|
@ -14,9 +14,8 @@ import {CtorParameter} from '../../../src/ngtsc/reflection';
|
||||
* names.
|
||||
*/
|
||||
export function expectTypeValueReferencesForParameters(
|
||||
parameters: CtorParameter[], expectedParams: (string | null)[],
|
||||
fromModule: string | null = null) {
|
||||
parameters !.forEach((param, idx) => {
|
||||
parameters: CtorParameter[], expectedParams: (string|null)[], fromModule: string|null = null) {
|
||||
parameters!.forEach((param, idx) => {
|
||||
const expected = expectedParams[idx];
|
||||
if (expected !== null) {
|
||||
if (param.typeValueReference === null) {
|
||||
@ -32,7 +31,7 @@ export function expectTypeValueReferencesForParameters(
|
||||
expect(param.typeValueReference.expression.text).toEqual(expected);
|
||||
}
|
||||
} else if (param.typeValueReference !== null) {
|
||||
expect(param.typeValueReference.moduleName).toBe(fromModule !);
|
||||
expect(param.typeValueReference.moduleName).toBe(fromModule!);
|
||||
expect(param.typeValueReference.name).toBe(expected);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user