Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const stateImportPath = buildRelativePath(componentPath, statePath);
const storeImport = insertImport(
source,
componentPath,
'Store',
'@ngrx/store'
);
const stateImport = options.state
? insertImport(
source,
componentPath,
`* as fromStore`,
stateImportPath,
true
)
: new NoopChange();
const componentClass = source.statements.find(
stm => stm.kind === ts.SyntaxKind.ClassDeclaration
);
const component = componentClass as ts.ClassDeclaration;
const componentConstructor = component.members.find(
member => member.kind === ts.SyntaxKind.Constructor
);
const cmpCtr = componentConstructor as ts.ConstructorDeclaration;
const { pos } = cmpCtr;
const stateType = options.state
? `fromStore.${options.stateInterface}`
: 'any';
const constructorText = cmpCtr.getText();
const [start, end] = constructorText.split('()');
const storeText = `private store: Store<${stateType}>`;