One of the problems of moment-timezone is that it gives you a warning if you include it multiple times. I have a module that requires the timezone. Because I don't know if whoever is using will or will not set the timezone themself, I have the following:
if (moment.tz === undefined) {
require('moment-timezone');
moment.tz.setDefault('America/Los_Angeles');
}
This works fine in normal Javascript. I recently was experimenting to switch to Typscript, and when I do this, I get the error that Cannot find name 'require'.
I switched that line to import momentTimezone = require('moment-timezone'); but then get An import declaration can only be used in a namespace or module.
What can I do?
import momentTimezone =...attempt came from). But that also doesn't work :(import {...} from '...'). Dynamic requires necessitate using the require function as a loader-specific function.