Conform more code to strict null checking (#10167)

* Conform more code to strict null checking

* Delint

* Iterate PR based on feedback
This commit is contained in:
Michael Telatynski 2023-02-16 17:21:44 +00:00 committed by GitHub
parent f7bea2cae5
commit 4574c665ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
103 changed files with 517 additions and 495 deletions

View file

@ -437,7 +437,7 @@ export default class SettingsStore {
level: SettingLevel,
roomId: string | null,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
let resultingValue = calculatedValue;

View file

@ -36,7 +36,7 @@ export default class IncompatibleController extends SettingController {
level: SettingLevel,
roomId: string,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
if (this.incompatibleSetting) {
return this.forcedValue;

View file

@ -53,7 +53,7 @@ export class NotificationsEnabledController extends SettingController {
level: SettingLevel,
roomId: string,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
if (!getNotifier().isPossible()) return false;

View file

@ -35,7 +35,7 @@ export class OrderedMultiController extends SettingController {
level: SettingLevel,
roomId: string,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
for (const controller of this.controllers) {
const override = controller.getValueOverride(level, roomId, calculatedValue, calculatedAtLevel);

View file

@ -27,7 +27,7 @@ export default class ReducedMotionController extends SettingController {
level: SettingLevel,
roomId: string,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
if (this.prefersReducedMotion()) {
return false;

View file

@ -41,7 +41,7 @@ export default abstract class SettingController {
level: SettingLevel,
roomId: string | null,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
return null; // no override
}

View file

@ -26,7 +26,7 @@ export default class ThemeController extends SettingController {
level: SettingLevel,
roomId: string,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
if (!calculatedValue) return null; // Don't override null themes

View file

@ -34,7 +34,7 @@ export default class UIFeatureController extends SettingController {
level: SettingLevel,
roomId: string,
calculatedValue: any,
calculatedAtLevel: SettingLevel,
calculatedAtLevel: SettingLevel | null,
): any {
if (this.settingDisabled) {
// per the docs: we force a disabled state when the feature isn't active

View file

@ -22,7 +22,7 @@ const SIZE_LARGE = { w: 800, h: 600 };
const SIZE_NORMAL_LANDSCAPE = { w: 324, h: 324 }; // for w > h
const SIZE_NORMAL_PORTRAIT = { w: Math.ceil(324 * (9 / 16)), h: 324 }; // for h > w
type Dimensions = { w: number; h: number };
type Dimensions = { w?: number; h?: number };
export enum ImageSize {
Normal = "normal",
@ -36,7 +36,7 @@ export enum ImageSize {
* @returns {Dimensions} The suggested maximum dimensions for the image
*/
export function suggestedSize(size: ImageSize, contentSize: Dimensions, maxHeight?: number): Dimensions {
const aspectRatio = contentSize.w / contentSize.h;
const aspectRatio = contentSize.w! / contentSize.h!;
const portrait = aspectRatio < 1;
const maxSize = size === ImageSize.Large ? SIZE_LARGE : portrait ? SIZE_NORMAL_PORTRAIT : SIZE_NORMAL_LANDSCAPE;