Closed iway1 closed 2 years ago
To get a list of all available names for the currently-loaded dataset, you can call moment.tz.names()
. This list should mostly match the more detailed version at https://en.wikipedia.org/wiki/List_of_tz_database_time_zones (they both come from the same data source).
However, I don't think the type definitions should use anything more specific than string
, for a few reasons:
moment-timezone
, there are a lot of possible values. In version 0.5.34 the .names()
function returns an array of 594 strings.@iway1 just write a script that patches your type-script bindings via moment.tz.names locally and be happy. No need to push this usecase to all users, as @gilmoreorless pointed out, there are good reasons against it.
Also, the idea of all these timezones is to select one at runtime, if you are going to hardcode a string in your code, then you should know which one you want. Also, if it's one or a few you might re-compile the tzdata to only include those zones and save on a lof of bandwidth (if this is client-side). I can't possibly see a use case where a developer is like "umm which timezone should I hardcode, let the IDE help me out".
Version: any
Issue description:
not even sure where I can find list of available timezone strings, the
.tz
function should accept a more strongly typed parameter instead of juststring
to prevent developer error and provide autocomplete.