const PROGRAMING_LANGUAGE = {
python : "Python",
javascript : "JavaScript"
} as const;
type PROGRAMING_LANGUAGE = typeof PROGRAMING_LANGUAGE[keyof typeof PROGRAMING_LANGUAGE];
const arg1 : PROGRAMING_LANGUAGE = PROGRAMING_LANGUAGE.python
compiled
var PROGRAMING_LANGUAGE = {
python: "Python",
javascript: "JavaScript"
};
var arg1 = PROGRAMING_LANGUAGE.python;
but using enum
enum PROGRAMING_LANGUAGE_ENUM {
python = "Python",
javascript = "JavaScript",
}
const arg2: PROGRAMING_LANGUAGE_ENUM = PROGRAMING_LANGUAGE_ENUM.javascript;
compiled
var PROGRAMING_LANGUAGE_ENUM;
(function (PROGRAMING_LANGUAGE_ENUM) {
PROGRAMING_LANGUAGE_ENUM["python"] = "Python";
PROGRAMING_LANGUAGE_ENUM["javascript"] = "JavaScript";
})(PROGRAMING_LANGUAGE_ENUM || (PROGRAMING_LANGUAGE_ENUM = {}));
var arg2 = PROGRAMING_LANGUAGE_ENUM.javascript;
enum is not working tree-shaking just code is The cord is getting longer.
tree-shaking is to delete code when code not use