I have recently been alerted to an "error" by Visual Studio Code in the following snippet:
someDateObject.toLocaleDateString('de-DE', Travel.dateOptions));
someDateObject.toLocaleDateString('de-DE', Travel.dateOptions));
Where Travel.dateOptions is defined as such:
public static dateOptions = { year: 'numeric', month: '2-digit', day: '2-digit' };
This has been working fine for the better part of the last 2 years, but upon opening the class inside VSC recently, it displayed following error for Travel.dateOptions:
Argument of type '{ year: string; month: string; day: string; }' is not assignable to parameter of
type 'DateTimeFormatOptions'.
Types of property 'year' are incompatible.
Type 'string' is not assignable to type '"numeric" | "2-digit"'. ts(2345)
I am dead confused as to why. Is this possibly a bug with VSC? The code seems to work fine (and has worked fine the entire time) once compiled - and according to the documentation for Date::toLocaleDateString() what I'm doing here seems perfectly valid.
Any ideas?