Created
June 30, 2021 07:03
-
-
Save NitsanBaleli/cbaad33ebd18d3ab29b38fd8f94787d0 to your computer and use it in GitHub Desktop.
typescript enum alternative
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//https://stackoverflow.com/a/60041791/2460773 | |
//https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums | |
export const mapConsumptionActiveMapType = { | |
elevation: "map", | |
orthomosaic: "elevation", | |
model_3d: "3d model", | |
} as const; | |
export type MapConsumptionActiveMapType = keyof typeof mapConsumptionActiveMapType; | |
let value: keyof typeof mapConsumptionActiveMapType; | |
for (value in mapConsumptionActiveMapType) { | |
const translationKey = mapConsumptionActiveMapType[value]; | |
if (value === "model_3d" && !mapGroup.model_3d) return; | |
radios.push( | |
<PrRadio.Button value={value}> | |
{t(translationKey as DynamicTranslationKey)} | |
</PrRadio.Button> | |
); | |
} |
IlanFrumer
commented
Jun 30, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment