Skip to content

Commit

Permalink
chore: post 2.0 upgrade adaptions (#1020)
Browse files Browse the repository at this point in the history
* docs: use new destroy subject signature
* chore(schematics): use eslint no-explicit-any in lazy component
* chore(schematics): code adaptions for subscribe deprecation in schematics
      - run "npx rxjs-fixers-morph ./tsconfig.json" for automatic migration
* chore: remove unused exports in main.server
* docs: add note to migrations.md
  • Loading branch information
dhhyi authored and MaxKless committed Feb 21, 2022
1 parent 6db7f7d commit a40a6e4
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 17 deletions.
3 changes: 2 additions & 1 deletion docs/concepts/localization.md
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ If you want to get the translation for a key within a component file, you have t
```typescript
export class ProductTileComponent implements OnDestroy {
...
destroy$ = new Subject();
private destroy$ = new Subject<void>();
constructor(protected translate: TranslateService) {}
...
toggleCompare() {
Expand All @@ -164,6 +164,7 @@ export class ProductTileComponent implements OnDestroy {
...
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
}
```
Expand Down
2 changes: 1 addition & 1 deletion docs/guides/angular-component-development.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ Following the ideas of the article [RxJS: Don’t Unsubscribe](https://benlesh.m
```typescript
export class AnyComponent implements OnInit, OnDestroy {
...
private destroy$ = new Subject();
private destroy$ = new Subject<void>();
...
ngOnInit() {
...
Expand Down
3 changes: 3 additions & 0 deletions docs/guides/migrations.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ The following official guides might help to migrate custom code as well:
- https://github.com/ngx-formly/ngx-formly/blob/v6.0.0-next.7/UPGRADE-6.0.md
- https://swiperjs.com/migration-guide

To help with the necessary rxjs refactorings, consider using [rxjs-fixers-morph](https://github.com/timdeschryver/rxjs-fixers-morph).
Simply run `npx rxjs-fixers-morph ./tsconfig.json`.

## 1.1 to 1.2

The `dist` folder now only contains results of the build process (except for `healthcheck.js`).
Expand Down
9 changes: 6 additions & 3 deletions schematics/src/cms-component/factory_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,12 @@ describe('CMS Component Schematic', () => {

it('should throw when definitionQualifiedName is missing', done => {
const options = { ...defaultOptions, definitionQualifiedName: undefined };
schematicRunner.runSchematicAsync('cms-component', options, appTree).subscribe(noop, err => {
expect(err).toMatchInlineSnapshot(`[Error: Option (definitionQualifiedName) is required.]`);
done();
schematicRunner.runSchematicAsync('cms-component', options, appTree).subscribe({
next: noop,
error: err => {
expect(err).toMatchInlineSnapshot(`[Error: Option (definitionQualifiedName) is required.]`);
done();
},
});
});
});
9 changes: 6 additions & 3 deletions schematics/src/component/factory_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,10 @@ describe('Component Schematic', () => {

it('should fail if specified module does not exist', done => {
const options = { ...defaultOptions, module: '/src/app.moduleXXX.ts' };
schematicRunner.runSchematicAsync('component', options, appTree).subscribe(noop, err => {
expect(err).toMatchInlineSnapshot(`
schematicRunner.runSchematicAsync('component', options, appTree).subscribe({
next: noop,
error: err => {
expect(err).toMatchInlineSnapshot(`
[Error: Specified module '/src/app.moduleXXX.ts' does not exist.
Looked in the following directories:
/src/app/src/app.moduleXXX.ts
Expand All @@ -157,7 +159,8 @@ describe('Component Schematic', () => {
/src/app
/src]
`);
done();
done();
},
});
});

Expand Down
9 changes: 6 additions & 3 deletions schematics/src/extension/factory_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,12 @@ export class AppModule { }

const options = { ...defaultOptions };

schematicRunner.runSchematicAsync('extension', options, appTree).subscribe(noop, err => {
expect(err).toMatchInlineSnapshot(`[Error: did not find 'AppLastRoutingModule' in /src/app/app.module.ts]`);
done();
schematicRunner.runSchematicAsync('extension', options, appTree).subscribe({
next: noop,
error: err => {
expect(err).toMatchInlineSnapshot(`[Error: did not find 'AppLastRoutingModule' in /src/app/app.module.ts]`);
done();
},
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class <%= classify(name) %>Component implements OnInit <% if (bindings.le
@ViewChild('anchor', { read: ViewContainerRef, static: true }) anchor: ViewContainerRef;
<% if (bindings.length) { %><%= bindings.map(b => b.declaration).join('\n ') %><% } %>

<% if (bindings.length) { %>// tslint:disable-next-line: no-any - access in on-changes required
<% if (bindings.length) { %>// eslint-disable-next-line @typescript-eslint/no-explicit-any -- access in on-changes required
private component: ComponentRef<any>;<% } %>

constructor(
Expand Down
9 changes: 6 additions & 3 deletions schematics/src/store/factory_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,12 @@ describe('Store Schematic', () => {
it('should throw if both feature and extension are supplied', done => {
const options = { ...defaultOptions, extension: 'feature', feature: 'bar' };

schematicRunner.runSchematicAsync('store', options, appTree).subscribe(fail, err => {
expect(err).toMatchInlineSnapshot(`[Error: cannot add feature store in extension]`);
done();
schematicRunner.runSchematicAsync('store', options, appTree).subscribe({
next: fail,
error: err => {
expect(err).toMatchInlineSnapshot(`[Error: cannot add feature store in extension]`);
done();
},
});
});

Expand Down
2 changes: 0 additions & 2 deletions src/main.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ if (PRODUCTION_MODE) {
}

export { AppServerModule } from './app/app.server.module';
export { ngExpressEngine } from '@nguniversal/express-engine';
export { environment } from './environments/environment';
export { HYBRID_MAPPING_TABLE, ICM_WEB_URL } from './hybrid/default-url-mapping-table';
export { renderModule, renderModuleFactory } from '@angular/platform-server';
export { APP_BASE_HREF } from '@angular/common';

0 comments on commit a40a6e4

Please sign in to comment.