Skip to content

Commit be822cf

Browse files
committed
chore: enable strict mode
1 parent 7d0f885 commit be822cf

File tree

6 files changed

+42
-26
lines changed

6 files changed

+42
-26
lines changed

projects/elements/src/lib/lazy-elements/lazy-element-dynamic/lazy-element-dynamic.directive.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ const LOG_PREFIX = '@angular-extensions/elements';
2727
selector: '[axLazyElementDynamic]',
2828
})
2929
export class LazyElementDynamicDirective implements OnInit, OnDestroy {
30-
@Input('axLazyElementDynamic') tag: string;
31-
@Input('axLazyElementDynamicUrl') url: string; // eslint-disable-line @angular-eslint/no-input-rename
30+
@Input('axLazyElementDynamic') tag: string | null = null;
31+
@Input('axLazyElementDynamicUrl') url: string | null = null; // eslint-disable-line @angular-eslint/no-input-rename
3232
@Input('axLazyElementDynamicLoadingTemplate') // eslint-disable-line @angular-eslint/no-input-rename
33-
loadingTemplateRef: TemplateRef<any>;
33+
loadingTemplateRef: TemplateRef<any> | null = null;
3434
@Input('axLazyElementDynamicErrorTemplate') // eslint-disable-line @angular-eslint/no-input-rename
35-
errorTemplateRef: TemplateRef<any>;
36-
@Input('axLazyElementDynamicModule') isModule: boolean | undefined; // eslint-disable-line @angular-eslint/no-input-rename
37-
@Input('axLazyElementDynamicImportMap') importMap: boolean | undefined; // eslint-disable-line @angular-eslint/no-input-rename
35+
errorTemplateRef: TemplateRef<any> | null = null;
36+
@Input('axLazyElementDynamicModule') isModule = false; // eslint-disable-line @angular-eslint/no-input-rename
37+
@Input('axLazyElementDynamicImportMap') importMap = false; // eslint-disable-line @angular-eslint/no-input-rename
3838

39-
private viewRef: EmbeddedViewRef<any> = null;
39+
private viewRef: EmbeddedViewRef<any> | null = null;
4040
private subscription = Subscription.EMPTY;
4141

4242
constructor(
@@ -67,9 +67,10 @@ export class LazyElementDynamicDirective implements OnInit, OnDestroy {
6767
}
6868
}
6969

70+
const tag = this.tag!;
71+
7072
const elementConfig =
71-
this.elementsLoaderService.getElementConfig(this.tag) ||
72-
({} as ElementConfig);
73+
this.elementsLoaderService.getElementConfig(tag) || ({} as ElementConfig);
7374
const options = this.elementsLoaderService.options;
7475
const loadingComponent =
7576
elementConfig.loadingComponent || options.loadingComponent;
@@ -84,22 +85,22 @@ export class LazyElementDynamicDirective implements OnInit, OnDestroy {
8485
const loadElement$ = from(
8586
this.elementsLoaderService.loadElement(
8687
this.url,
87-
this.tag,
88+
tag,
8889
this.isModule,
8990
this.importMap,
9091
elementConfig?.hooks
9192
)
9293
);
9394

9495
this.subscription = loadElement$
95-
.pipe(mergeMap(() => customElements.whenDefined(this.tag)))
96+
.pipe(mergeMap(() => customElements.whenDefined(tag)))
9697
.subscribe({
9798
next: () => {
9899
this.vcr.clear();
99100
const originalCreateElement = this.renderer.createElement;
100101
this.renderer.createElement = (name: string, namespace: string) => {
101102
if (name === 'ax-lazy-element') {
102-
name = this.tag;
103+
name = tag;
103104
}
104105
return this.document.createElement(name);
105106
};

projects/elements/src/lib/lazy-elements/lazy-element/lazy-element.directive.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ const LOG_PREFIX = '@angular-extensions/elements';
3434
selector: '[axLazyElement]',
3535
})
3636
export class LazyElementDirective implements OnChanges, OnInit, OnDestroy {
37-
@Input('axLazyElement') url: string;
38-
@Input('axLazyElementLoadingTemplate') loadingTemplateRef: TemplateRef<any>; // eslint-disable-line @angular-eslint/no-input-rename
39-
@Input('axLazyElementErrorTemplate') errorTemplateRef: TemplateRef<any>; // eslint-disable-line @angular-eslint/no-input-rename
40-
@Input('axLazyElementModule') isModule: boolean | undefined; // eslint-disable-line @angular-eslint/no-input-rename
41-
@Input('axLazyElementImportMap') importMap: boolean | undefined; // eslint-disable-line @angular-eslint/no-input-rename
37+
@Input('axLazyElement') url: string | null = null;
38+
@Input('axLazyElementLoadingTemplate') // eslint-disable-line @angular-eslint/no-input-rename
39+
loadingTemplateRef: TemplateRef<any> | null = null;
40+
@Input('axLazyElementErrorTemplate') // eslint-disable-line @angular-eslint/no-input-rename
41+
errorTemplateRef: TemplateRef<any> | null = null;
42+
@Input('axLazyElementModule') isModule = false; // eslint-disable-line @angular-eslint/no-input-rename
43+
@Input('axLazyElementImportMap') importMap = false; // eslint-disable-line @angular-eslint/no-input-rename
4244

43-
private viewRef: EmbeddedViewRef<any> = null;
45+
private viewRef: EmbeddedViewRef<any> | null = null;
4446
private subscription = Subscription.EMPTY;
4547
private url$ = new BehaviorSubject<string | null>(null);
4648

projects/elements/src/lib/lazy-elements/lazy-elements-loader.service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ export class LazyElementsLoaderService {
8080
});
8181
}
8282

83-
getElementConfig(tag: string): ElementConfig {
83+
getElementConfig(tag: string): ElementConfig | undefined {
8484
return this.configs.find((config) => config.tag === tag);
8585
}
8686

@@ -101,7 +101,7 @@ export class LazyElementsLoaderService {
101101
}
102102

103103
async loadElement(
104-
url: string,
104+
url: string | null,
105105
tag: string,
106106
isModule?: boolean,
107107
importMap?: boolean,
@@ -123,7 +123,7 @@ export class LazyElementsLoaderService {
123123
} else if (importMap) {
124124
url = tag;
125125
} else {
126-
url = config.url;
126+
url = config!.url;
127127
}
128128
}
129129

@@ -192,7 +192,7 @@ export class LazyElementsLoaderService {
192192
this.stripUrlProtocol(url),
193193
new Promise<void>((resolve, reject) => (notifier = { resolve, reject }))
194194
);
195-
return notifier;
195+
return notifier!;
196196
}
197197

198198
private hasElement(url: string): boolean {

projects/elements/src/lib/lazy-elements/lazy-elements.tokens.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ export const LAZY_ELEMENTS_REGISTRY = new InjectionToken<LazyElementsRegistry>(
2222
}
2323
);
2424

25-
export interface LazyElementsRegistry {
26-
get: (url: string) => Promise<void>;
27-
set: (url: string, notifier: Promise<void>) => void;
25+
export interface LazyElementsRegistry extends Map<string, Promise<void>> {
26+
get: (url: string) => Promise<void> | undefined;
27+
set: (url: string, notifier: Promise<void>) => this;
2828
has: (url: string) => boolean;
2929
}

projects/elements/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"extends": "../../tsconfig.json",
3+
"files": [],
4+
"include": [],
5+
"references": [
6+
{
7+
"path": "./tsconfig.lib.json"
8+
},
9+
{
10+
"path": "./tsconfig.spec.json"
11+
}
12+
]
13+
}

projects/elements/tsconfig.lib.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"extends": "../../tsconfig.json",
33
"compilerOptions": {
4-
"outDir": "../../out-tsc/lib",
54
"target": "es2015",
5+
"strict": true,
66
"declaration": true,
77
"declarationMap": true,
88
"inlineSources": true,

0 commit comments

Comments
 (0)