Conform more of the codebase to strictNullChecks (#10602)

* Conform more of the codebase to `strictNullChecks`

* Conform more of the codebase to `strictNullChecks`

* Fix types
This commit is contained in:
Michael Telatynski 2023-04-17 08:31:58 +01:00 committed by GitHub
parent 93858813a3
commit daad630827
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 79 additions and 49 deletions

View file

@ -44,7 +44,7 @@ export default class Resizer<C extends IConfig = IConfig> {
// TODO move vertical/horizontal to config option/container class
// as it doesn't make sense to mix them within one container/Resizer
public constructor(
public container: HTMLElement,
public container: HTMLElement | null,
private readonly distributorCtor: {
new (item: ResizeItem): FixedDistributor<C, any>;
createItem(
@ -53,7 +53,7 @@ export default class Resizer<C extends IConfig = IConfig> {
sizer: Sizer,
container?: HTMLElement,
): ResizeItem;
createSizer(containerElement: HTMLElement, vertical: boolean, reverse: boolean): Sizer;
createSizer(containerElement: HTMLElement | null, vertical: boolean, reverse: boolean): Sizer;
},
public readonly config?: C,
) {
@ -71,13 +71,13 @@ export default class Resizer<C extends IConfig = IConfig> {
public attach(): void {
const attachment = this?.config?.handler?.parentElement ?? this.container;
attachment.addEventListener("mousedown", this.onMouseDown, false);
attachment?.addEventListener("mousedown", this.onMouseDown, false);
window.addEventListener("resize", this.onResize);
}
public detach(): void {
const attachment = this?.config?.handler?.parentElement ?? this.container;
attachment.removeEventListener("mousedown", this.onMouseDown, false);
attachment?.removeEventListener("mousedown", this.onMouseDown, false);
window.removeEventListener("resize", this.onResize);
}
@ -194,7 +194,7 @@ export default class Resizer<C extends IConfig = IConfig> {
const Distributor = this.distributorCtor;
const useItemContainer = this.config?.handler ? this.container : undefined;
const sizer = Distributor.createSizer(this.container, vertical, reverse);
const item = Distributor.createItem(resizeHandle, this, sizer, useItemContainer);
const item = Distributor.createItem(resizeHandle, this, sizer, useItemContainer ?? undefined);
const distributor = new Distributor(item);
return { sizer, distributor };
}