Open Cyber1000 opened 8 years ago
Looks like someone else has created a typings for this. Isn't very hard as you can see - https://github.com/nozzlegear/dateformat.d.ts
It is simple enough to declare your own, but much more convenient if this is included in the lib. This is what I am using:
declare module 'dateformat' {
interface _dateformat {
/**
* Returns a string representing date using format mask.
*
* @param {Date} date The date
* @param {string} mask The format mask
*/
(date: Date, mask: string): string
/**
* Returns a string representing date using the default
* format mask.
*
* @param {Date} date The date
*/
(date: Date): string
/**
* Returns a string representing the current date (now)
* using format mask.
*
* @param {string} mask The format mask
*/
(mask: string): string
readonly masks: {
default: string,
shortDate: string,
mediumDate: string,
longDate: string,
fullDate: string,
shortTime: string,
mediumTime: string,
longTime: string,
isoDate: string,
isoTime: string,
isoDateTime: string,
isoUtcDateTime: string,
expiresHeaderFormat: string
}
i18n: {
dateNames: string[],
monthNames: string[]
}
}
let dateformat: _dateformat
export default dateformat;
}
It could probably use a little more jsdoc describing the masks, and how to override i18n, but it works for me. I could create a pull request if you want...
There is a separate npm package with typings: @types/dateformat that you can install.
I'm using your component, but I would like to use it a little bit more typesave. I'm using typescript: Is there some typedefintion out there for dateformat (official/inofficial) or are you planning to provide one .d.ts-File?
Thanks!