Skip to content

Commit

Permalink
chore(workbench-client): compile with TypeScript strict checks enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
mofogasy committed May 25, 2021
1 parent 119e2e6 commit 3e9a0ca
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class MessageBoxOpenerPageComponent {
const currentView = Beans.get(WorkbenchView);
const unsetViewContext = (this.form.get(VIEW_CONTEXT).value === false);

unsetViewContext && Beans.register(WorkbenchView, {useValue: undefined});
unsetViewContext && Beans.register(WorkbenchView, {useValue: null});
try {
this._messageBoxService.open({
title: this.form.get(TITLE).value.replace(/\\n/g, '\n') || undefined, // restore line breaks as sanitized by the user agent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export class WorkbenchPopupService {
// To be able to integrate popups from apps without workbench integration, we do not delegate the opening of the popup to
// the app that provides the requested popup, but interact with the workbench directly. Nevertheless, we issue an intent
// so that the platform throws an error in case of unqualified interaction.
await Beans.get(IntentClient).publish<WorkbenchPopupConfig>({type: WorkbenchCapabilities.Popup, qualifier, params: Maps.coerce(config.params)}, {...config, anchor: undefined});
await Beans.get(IntentClient).publish<WorkbenchPopupConfig>({type: WorkbenchCapabilities.Popup, qualifier, params: Maps.coerce(config.params)}, {...config, anchor: undefined!});

const view = Beans.opt(WorkbenchView);
const popupCommand: ɵWorkbenchPopupCommand = {
Expand All @@ -85,7 +85,7 @@ export class WorkbenchPopupService {
]),
context: {
viewId: view?.viewId,
capabilityId: await view?.capability$.pipe(map(capability => capability.metadata.id), take(1)).toPromise(),
capabilityId: await view?.capability$.pipe(map(capability => capability.metadata!.id), take(1)).toPromise(),
},
};
const popupOriginPublisher = this.observePopupOrigin$(config).subscribe(origin => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,12 @@ export abstract class WorkbenchPopup {
/**
* Capability that represents the microfrontend loaded into this workbench popup.
*/
public readonly capability: WorkbenchPopupCapability;
public readonly capability!: WorkbenchPopupCapability;

/**
* Parameters including qualifier entries as passed for navigation by the popup opener.
*/
public readonly params: Map<string, any>;
public readonly params!: Map<string, any>;

/**
* Closes the popup. Optionally, pass a result to the popup opener.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export class WorkbenchRouter {
const {intent, capability} = await this.currentNavigation();
return {
capabilities: [capability],
qualifier: intent.qualifier,
qualifier: intent.qualifier ?? {},
extras: {
...extras,
target: 'self',
Expand Down Expand Up @@ -133,7 +133,7 @@ export class WorkbenchRouter {

return {
capability: currentCapability,
intent: this.deriveViewIntent(currentCapability.qualifier, currentParams),
intent: this.deriveViewIntent(currentCapability.qualifier ?? {}, currentParams),
};
}

Expand All @@ -154,7 +154,7 @@ export class WorkbenchRouter {
* Derives the intent that was issued to open the view of the passed capability.
*/
private deriveViewIntent(capabilityQualifier: Qualifier, params: Map<string, any>): Intent {
const intentQualifier = Object.entries(capabilityQualifier).reduce((acc, [key, value]) => {
const intentQualifier = Object.entries(capabilityQualifier).reduce<Qualifier>((acc, [key, value]) => {
if (!params.has(key) && value !== '?') {
throw Error(`[ViewContextError] Missing required qualifier param '${key}'.`);
}
Expand Down
12 changes: 6 additions & 6 deletions projects/scion/workbench-client/src/lib/view/workbench-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export abstract class WorkbenchView {
/**
* Represents the identity of this workbench view.
*/
public readonly viewId: string;
public readonly viewId!: string;

/**
* Observable containing the view capability that represents the microfrontend loaded into this workbench view.
Expand All @@ -46,7 +46,7 @@ export abstract class WorkbenchView {
* or navigating to a microfrontend of another app. Consequently, do not forget to unsubscribe from this Observables before
* displaying another microfrontend.
*/
public readonly capability$: Observable<WorkbenchViewCapability>;
public readonly capability$!: Observable<WorkbenchViewCapability>;

/**
* Observable containing the parameters including the qualifier as passed for navigation in {@link WorkbenchNavigationExtras.params}.
Expand All @@ -56,7 +56,7 @@ export abstract class WorkbenchView {
* navigating to a microfrontend of another app. Consequently, do not forget to unsubscribe from this Observables before displaying
* another microfrontend.
*/
public readonly params$: Observable<Map<string, any>>;
public readonly params$!: Observable<Map<string, any>>;

/**
* Indicates whether this is the active view in its view part.
Expand All @@ -66,7 +66,7 @@ export abstract class WorkbenchView {
* the view or navigating to a microfrontend of another app. Consequently, do not forget to unsubscribe from this Observables before displaying
* another microfrontend.
*/
public readonly active$: Observable<boolean>;
public readonly active$!: Observable<boolean>;

/**
* Sets the title to be displayed in the view tab.
Expand Down Expand Up @@ -139,7 +139,7 @@ export class ɵWorkbenchView implements WorkbenchView, PreDestroy { // tslint:di
*/
private _beforeInAppNavigation$ = new Subject<void>();
private _closingListeners = new Set<ViewClosingListener>();
private _closingSubscription: Subscription;
private _closingSubscription: Subscription | null = null;

public active$: Observable<boolean>;
public capability$: Observable<WorkbenchViewCapability>;
Expand Down Expand Up @@ -405,7 +405,7 @@ function lookupViewCapabilityAndShareReplay(): OperatorFunction<string, Workbenc
shareReplay({refCount: true, bufferSize: 1}),
// Ensure not to replay a stale capability upon the subscription of new subscribers. For this reason, we install a filter to filter them out.
// The 'shareReplay' operator would replay a stale capability if the source has emitted a new capability id, but the lookup for it did not complete yet.
filter(viewCapability => latestViewCapabilityId === viewCapability.metadata.id),
filter(viewCapability => latestViewCapabilityId === viewCapability.metadata!.id),
);
}

11 changes: 9 additions & 2 deletions projects/scion/workbench-client/tsconfig.lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@
"declarationMap": true,
"stripInternal": true,
"inlineSources": true,
"types": []
"types": [],
"forceConsistentCasingInFileNames": true,
"strict": true,
"noImplicitReturns": true,
"noFallthroughCasesInSwitch": true
},
"angularCompilerOptions": {
"skipTemplateCodegen": true,
"strictMetadataEmit": true,
"enableResourceInlining": true
"enableResourceInlining": true,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true,
"strictTemplates": true
},
"exclude": [
"src/test.ts",
Expand Down
5 changes: 4 additions & 1 deletion projects/scion/workbench-client/tslint.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../../tslint.json"
"extends": "../../../tslint.json",
"rules": {
"no-non-null-assertion": false
}
}

0 comments on commit 3e9a0ca

Please sign in to comment.