Hi, I have a question about TypeScript and luxon.
Under luxon 3.2.x, I can use like that:
import { DateTime } from 'luxon';
function getNowISOStr(): string {
const now = DateTime.local();
// this is OK under 3.2.x
const iso = now.toISO({ includeOffset: true });
return iso;
}
But under luxon 3.3.x, I can't use like that:
import { DateTime } from 'luxon';
function getNowISOStr(): string {
const now = DateTime.local();
// this is not working under 3.3.x
// Because toISO() returns string | null
// So iso variable not match string return type
const iso = now.toISO({ includeOffset: true });
return iso;
}
So every times I have to use like that: now.toISO({ includeOffset: true })!; // add '!' character
I think this is not good way. Because I get non-nullable and valid DateTime instance just before.
How can I write better way? without using ! operator.