I have a function that uses moment.js
. I am new to typescript and jsdoc imports and I'm wondering how I can document that a function returns, specifically a moment object:
const moment = require('moment-timezone');
/**
* @typedef Moment
* @property {import('moment-timezone').Moment} moment
*/
/**
* Returns a moment object with the date / time converted to the given timezone
* @param {Date} dateTime
* @param {string} targetTimeZone
* @return {Moment}
*/
const convertDateTimeToLocationTimeZone = (dateTime, targetTimeZone) => {
return moment(dateTime).tz(targetTimeZone);
};
I'm not even sure if the above is totally off - but also the above gives me this error in vscode:
Property 'moment' is missing in type 'import("/Users/Deb/Desktop/project/node_modules/moment/....").Moment' but required in type 'import("/Users/Deb/Desktop/project/...").Moment'.
Note, I do have @types/moment-timezone
installed.