dmtrKovalenko / date-io

Abstraction over common javascript date management libraries
MIT License
726 stars 90 forks source link

Change `TDate` to an extendable type #603

Closed selenehyun closed 2 years ago

selenehyun commented 2 years ago

This change gives you an advantage when developing with date-io.

If you extend the type as shown below in a project using date-io, you can set the Opaque type so that the Date value is not directly referenced.

declare module '@date-io/core' {
  type Opaque<K, T> = T & { __TYPE__: K };

  interface ExtendableDateType extends Opaque<'DateType', unknown> {}
}

This allows me to take advantage of TypeScript more powerfully by not dealing with the any type.