Skip to content

Commit

Permalink
fix(schematics): components should inject the store without generic (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
timdeschryver authored May 8, 2020
1 parent 831e1e4 commit 4f7dcdc
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { provideMockStore, MockStore } from '@ngrx/store/testing';
describe('<%= classify(name) %>Component', () => {
let component: <%= classify(name) %>Component;
let fixture: ComponentFixture<<%= classify(name) %>Component>;
let store: MockStore<any>;
let store: MockStore;

beforeEach(async() => {
TestBed.configureTestingModule({
Expand Down
5 changes: 2 additions & 3 deletions modules/schematics/src/container/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ describe('Container Schematic', () => {
const content = tree.readContent(
`${projectPath}/src/app/foo/foo.component.ts`
);
expect(content).toMatch(
/constructor\(private store\: Store\<fromStore\.State\>\) { }\n\n/
);

expect(content).toMatch(/constructor\(private store\: Store\) { }\n\n/);
});

it('should update the component spec', async () => {
Expand Down
6 changes: 1 addition & 5 deletions modules/schematics/src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,9 @@ function addStateToComponent(options: Partial<ContainerOptions>) {
);
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}>`;
const storeConstructor = [start, `(${storeText})`, end].join('');
const storeConstructor = [start, `(private store: Store)`, end].join('');
const constructorUpdate = new ReplaceChange(
componentPath,
pos,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Store, StoreModule } from '@ngrx/store';
describe('<%= classify(name) %>Component', () => {
let component: <%= classify(name) %>Component;
let fixture: ComponentFixture<<%= classify(name) %>Component>;
let store: Store<any>;
let store: Store;

beforeEach(async() => {
TestBed.configureTestingModule({
Expand Down

0 comments on commit 4f7dcdc

Please sign in to comment.