fix: resolve noNonNullAssertion and noImplicitAnyLet lint issues (#27021)

Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Volnei Munhoz
2026-01-19 20:07:18 -03:00
committed by GitHub
co-authored by Devin AI
parent 12e42427e2
commit e620264848
24 changed files with 57 additions and 46 deletions
+8 -6
View File
@@ -483,7 +483,9 @@ export class Cal {
// linkReady event isn't received anyway by parent as it isn't whitelisted to be sent to parent but it is a safe guard
return;
}
this.iframe!.style.visibility = "";
if (this.iframe) {
this.iframe.style.visibility = "";
}
// Removes the loader
// TODO: We should be using consistent approach of "state" attribute for modalBox and inlineEl.
@@ -1052,7 +1054,7 @@ class CalApi {
const { embedConfig: previousEmbedConfig, embedRenderStartTime: previousEmbedRenderStartTime } =
this.cal.getPreviousModalRenderStartVariables();
let enrichedConfig;
let enrichedConfig: PrefillAndIframeAttrsConfig;
const configWithGuestKeyAndColorScheme = withColorScheme(
Cal.ensureGuestKey({
...config,
@@ -1061,7 +1063,7 @@ class CalApi {
containerEl
);
let enrichedPrerenderOptions;
let enrichedPrerenderOptions: ModalPrerenderOptions | undefined;
if (isPrerendering) {
const preparationResult = this.cal.prepareForPrerender({
calLink,
@@ -1578,7 +1580,7 @@ document.addEventListener("click", (e) => {
const namespace = calLinkEl.dataset.calNamespace;
const configString = calLinkEl.dataset.calConfig || "";
const calOrigin = calLinkEl.dataset.calOrigin || "";
let config;
let config: PrefillAndIframeAttrsConfig;
try {
config = JSON.parse(configString);
} catch {
@@ -1602,7 +1604,7 @@ document.addEventListener("click", (e) => {
});
function getCalLinkEl(target: EventTarget | null) {
let calLinkEl;
let calLinkEl: HTMLElement | Element | undefined;
if (!(target instanceof HTMLElement)) {
return null;
}
@@ -1641,7 +1643,7 @@ let currentColorScheme: string | null = null;
})();
function getEmbedApiFn(ns: string) {
let api;
let api: GlobalCalWithoutNs | GlobalCal;
if (ns === DEFAULT_NAMESPACE) {
api = globalCal;
} else {
+3 -3
View File
@@ -458,9 +458,9 @@ export default abstract class BaseCalendarService implements Calendar {
startDate.second = event.startDate.second;
const iterator = event.iterator(startDate);
let current: ICAL.Time;
let currentEvent;
let currentStart = null;
let currentError;
let currentEvent: ReturnType<typeof event.getOccurrenceDetails> | undefined;
let currentStart: ReturnType<typeof dayjs> | null = null;
let currentError: string | undefined;
while (
maxIterations > 0 &&
+2 -2
View File
@@ -257,8 +257,8 @@ export default class CloseCom {
body: new URLSearchParams({
grant_type: "refresh_token",
refresh_token: this.refresh_token,
client_id: process.env.CLOSECOM_CLIENT_ID!,
client_secret: process.env.CLOSECOM_CLIENT_SECRET!,
client_id: process.env.CLOSECOM_CLIENT_ID ?? "",
client_secret: process.env.CLOSECOM_CLIENT_SECRET ?? "",
}),
});
+1 -1
View File
@@ -31,7 +31,7 @@ export function getAvailabilityFromSchedule(schedule: Schedule): Availability[]
} as Availability);
const filteredTimes = times.filter((time) => {
let idx;
let idx: number;
if (
(idx = availability.findIndex(
(schedule) =>
+5 -5
View File
@@ -245,7 +245,7 @@ const parseObjectComponents = (content: string, components: Record<string, React
// Find all placeholders in order
const placeholderRegex = /__(?:INTERP|TAG)_[^_]+_[a-z0-9]+__/g;
let match;
let match: RegExpExecArray | null;
while ((match = placeholderRegex.exec(processedContent)) !== null) {
const [placeholder] = match;
@@ -346,11 +346,11 @@ const parseHtmlTags = (content: string): ReactNode[] => {
// Find all placeholders in order
const placeholderRegex = /__HTML_[^_]+_[a-z0-9]+__/g;
let match;
let match2: RegExpExecArray | null;
while ((match = placeholderRegex.exec(processedContent)) !== null) {
const [placeholder] = match;
const index = match.index;
while ((match2 = placeholderRegex.exec(processedContent)) !== null) {
const [placeholder] = match2;
const index = match2.index;
// Add text before placeholder
if (index > lastIndex) {
@@ -10,7 +10,7 @@ export const useUrlMatchesCurrentUrl = (url: string, matchFullPath?: boolean) =>
const pathname = usePathname() as null | string;
const searchParams = useCompatSearchParams();
const query = searchParams?.toString();
let pathnameWithQuery;
let pathnameWithQuery: string | null;
if (query) {
pathnameWithQuery = `${pathname}?${query}`;
} else {
+1 -1
View File
@@ -183,7 +183,7 @@ export function getRollingWindowEndDate({
const log = logger.getSubLogger({ prefix: ["getRollingWindowEndDate"] });
log.debug("called:", safeStringify({ startDay: startDateInBookerTz.format(), daysNeeded }));
let counter = 1;
let rollingEndDay;
let rollingEndDay: ReturnType<typeof startDateInBookerTz.startOf> | undefined;
const startOfStartDayInEventTz = startDateInBookerTz.startOf("day");
// It helps to break out of the loop if we don't find enough bookable days.
const maxDaysToCheck = ROLLING_WINDOW_PERIOD_MAX_DAYS_TO_CHECK;
@@ -52,8 +52,7 @@ export function transformDateOverridesForAtom(
};
const dayRangeIndex = acc.findIndex(
// early return prevents override.date from ever being empty.
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
(item) => yyyymmdd(item.ranges[0].start) === yyyymmdd(override.date!)
(item) => override.date && yyyymmdd(item.ranges[0].start) === yyyymmdd(override.date)
);
if (dayRangeIndex === -1) {
acc.push({ ranges: [newValue] });
+1 -1
View File
@@ -28,7 +28,7 @@ export class Md5PiiHasher implements PiiHasher {
}
}
export const piiHasher: PiiHasher = new Md5PiiHasher(process.env.CALENDSO_ENCRYPTION_KEY!);
export const piiHasher: PiiHasher = new Md5PiiHasher(process.env.CALENDSO_ENCRYPTION_KEY ?? "");
export const hashEmail = (email: string, hasher: PiiHasher = piiHasher): string => {
const [localPart, domain] = email.split("@");
+2 -2
View File
@@ -23,7 +23,7 @@ export async function checkSMSRateLimit({
}
async function changeSMSLockState(identifier: string, status: SMSLockState) {
let userId, teamId;
let userId: number | undefined, teamId: number | undefined;
if (identifier.startsWith("sms:user:")) {
userId = Number(identifier.slice(9));
@@ -61,4 +61,4 @@ async function changeSMSLockState(identifier: string, status: SMSLockState) {
},
});
}
}
}
+1 -1
View File
@@ -30,7 +30,7 @@ const resolveEndpoint = (links: any) => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (ctx: any) => {
const parts = ctx.op.path.split(".");
let endpoint;
let endpoint: keyof typeof links;
let path = "";
if (parts.length == 2) {
endpoint = parts[0] as keyof typeof links;
@@ -363,7 +363,8 @@ export const formMutationHandler = async ({ ctx, input }: FormMutationHandlerOpt
});
}
let fields, routes;
let fields: NonNullable<typeof fieldsParsed.data>,
routes: NonNullable<typeof routesParsed.data>;
if (shouldConnect) {
routes = [
// This connected route would automatically link the fields
@@ -67,7 +67,7 @@ export const teamsAndUserProfilesQuery = async ({ ctx, input }: TeamsAndUserProf
throw new TRPCError({ code: "INTERNAL_SERVER_ERROR" });
}
let teamsData;
let teamsData: typeof user.teams extends (infer T)[] ? (T & { team: T extends { team: infer U } ? U & { metadata: ReturnType<typeof teamMetadataSchema.parse> } : never })[] : never;
if (input?.includeOrg) {
teamsData = user.teams
@@ -103,8 +103,8 @@ const editAttributesHandler = async ({ input, ctx }: GetOptions) => {
await validateOptionsBelongToAttribute(options, attributes.id);
await prisma.$transaction(async (tx) => {
const updateOptions = options.filter((option) => option.id !== undefined && option.id !== "");
const updatedOptionsIds = updateOptions.map((option) => option.id!);
const updateOptions = options.filter((option): option is typeof option & { id: string } => option.id !== undefined && option.id !== "");
const updatedOptionsIds = updateOptions.map((option) => option.id);
// We need to delete all options that are not present in this UpdateOptions.id (as they have been deleted)
await tx.attributeOption.deleteMany({
where: {
@@ -159,10 +159,9 @@ async function validateOptionsBelongToAttribute(
options: ZEditAttributeSchema["options"],
attributeId: string
) {
// We have to use ! here to make sure typescript knows that the id is not undefined
const optionsWithId = options
.filter((option) => option.id !== undefined && option.id !== "")
.map((option) => option.id!);
.filter((option): option is typeof option & { id: string } => option.id !== undefined && option.id !== "")
.map((option) => option.id);
// Check all ids of options passed in are owned by the attribute
const optionsWithIdOwnedByAttribute = await prisma.attributeOption.findMany({
@@ -28,7 +28,7 @@ export const resendVerifyEmail = async ({ input, ctx }: ResendEmailOptions) => {
});
let emailVerified = Boolean(ctx.user.emailVerified);
let secondaryEmail;
let secondaryEmail: Awaited<ReturnType<typeof prisma.secondaryEmail.findUnique>> | undefined;
// If the input which is coming is not the current user's email, it could be a secondary email
if (input?.email && input?.email !== ctx.user.email) {
secondaryEmail = await prisma.secondaryEmail.findUnique({
@@ -134,7 +134,7 @@ async function getAllCredentialsIncludeServiceAccountKey({
}) {
const credentials = await getUsersCredentialsIncludeServiceAccountKey(user);
let conferenceCredential;
let conferenceCredential: Awaited<ReturnType<typeof CredentialRepository.findFirstByIdWithKeyAndUser>> | undefined;
if (conferenceCredentialId) {
// Validate that the credential is accessible before fetching it
@@ -74,7 +74,7 @@ export const setDestinationCalendarHandler = async ({ ctx, input }: SetDestinati
const { credentialId, delegationCredentialId } = firstConnectedCalendar || {};
let where;
let where: { eventTypeId: number } | { userId: number };
if (!credentialId && !delegationCredentialId) {
throw new TRPCError({ code: "BAD_REQUEST", message: `Could not find calendar ${input.externalId}` });
@@ -82,8 +82,8 @@ export async function toggleDelegationCredentialEnabled(
log.error(`Delegation credential ${input.id} has no workspace platform slug`);
}
let calendarAppName;
let conferencingAppName;
let calendarAppName: string;
let conferencingAppName: string;
if (slug === "google") {
calendarAppName = "Google Calendar";
@@ -176,9 +176,9 @@ export const createEventPbacProcedure = (
const isAllowed = (function () {
if (event.team) {
const allTeamMembers = event.team.members.map((member) => member.userId);
return input.users!.every((userId: number) => allTeamMembers.includes(userId));
return input.users?.every((userId: number) => allTeamMembers.includes(userId)) ?? true;
}
return input.users!.every((userId: number) => userId === ctx.user.id);
return input.users?.every((userId: number) => userId === ctx.user.id) ?? true;
})();
if (!isAllowed) {
@@ -329,7 +329,7 @@ export const updateProfileHandler = async ({ ctx, input }: UpdateProfileOptions)
emailFrom: user.email,
// We know email has been changed here so we can use input
emailTo: input.email!,
emailTo: input.email ?? "",
},
});
}
@@ -45,7 +45,7 @@ export const outOfOfficeCreateOrUpdate = async ({ ctx, input }: TBookingRedirect
let oooUserOrgId = ctx.user.organizationId;
let oooUserFullName = ctx.user.name;
let isAdmin;
let isAdmin: boolean | undefined;
if (input.forUserId) {
isAdmin = await isAdminForUser(ctx.user.id, input.forUserId);
if (!isAdmin) {
@@ -283,7 +283,17 @@ export const listMembersHandler = async ({ ctx, input }: GetOptions) => {
const members = await Promise.all(
teamMembers?.map(async (membership) => {
const user = await new UserRepository(prisma).enrichUserWithItsProfile({ user: membership.user });
let attributes;
let attributes:
| Array<{
id: string;
value: string;
slug: string;
attributeId: string;
weight: number;
isGroup: boolean;
contains: string[];
}>
| undefined;
if (expand?.includes("attributes")) {
attributes = await prisma.attributeToUser
@@ -381,8 +381,8 @@ export class AvailableSlotsService {
}) {
if (!eventTypeSlug || !slug) return null;
let teamId;
let userId;
let teamId: number | undefined;
let userId: number | undefined;
if (isTeamEvent) {
teamId = await this.getTeamIdFromSlug(
slug,
@@ -1307,7 +1307,7 @@ export class AvailableSlotsService {
const restrictionTimezone = eventType.useBookerTimezone
? input.timeZone
: restrictionSchedule.timeZone!;
: restrictionSchedule.timeZone ?? "UTC";
const eventLength = input.duration || eventType.length;
const restrictionAvailability = restrictionSchedule.availability.map((rule) => ({
@@ -27,7 +27,7 @@ export const resendInvitationHandler = async ({ ctx, input }: InviteMemberOption
isOrg: input.isOrg,
});
let verificationToken;
let verificationToken: Awaited<ReturnType<typeof VerificationTokenRepository.updateTeamInviteTokenExpirationDate>> | undefined;
try {
verificationToken = await VerificationTokenRepository.updateTeamInviteTokenExpirationDate({