diff --git a/src/env/schema.mjs b/src/env/schema.mjs index 0d3cd36..8a1a8c3 100644 --- a/src/env/schema.mjs +++ b/src/env/schema.mjs @@ -1,8 +1,9 @@ // @ts-check import { z } from 'zod'; -// @ts-ignore +// If this line fails, you're not running Node v18 or higher. Please upgrade. const TimezoneSchema = z.enum(Intl.supportedValuesOf("timeZone")); + /** * Specify your server-side environment variables schema here. * This way you can ensure the app isn't built with invalid env vars. diff --git a/src/location.ts b/src/location.ts index 0560463..3c14656 100644 --- a/src/location.ts +++ b/src/location.ts @@ -56,7 +56,7 @@ export function distance( export async function getDistance(): Promise { let client; try { - // Setup the Life360 API client + // Set up the Life360 API client client = await life360.login(env.LIFE360_USERNAME, env.LIFE360_PASSWORD); } catch (e) { throw new Error( diff --git a/src/utils/timezone.ts b/src/utils/timezone.ts index 8bb906d..3130302 100644 --- a/src/utils/timezone.ts +++ b/src/utils/timezone.ts @@ -2,8 +2,11 @@ import { utcToZonedTime } from 'date-fns-tz'; import { z } from 'zod'; import { env } from '@/env/server.mjs'; -// @ts-ignore TS2339 -- TODO: Figure out why Intl.supportedValuesOf isn't seen by Typescript -export const TimezoneSchema = z.enum(Intl.supportedValuesOf('timeZone')); +// If this line fails in Typescript, then install typescript@^5.1.3 +export const TimezoneSchema = z.enum( + // 'as' to assume at least one element + Intl.supportedValuesOf('timeZone') as [string, ...string[]] +); export type Timezone = z.infer; export function localNow(now?: Date, zone?: Timezone): Date {