Skip to content

This repository contains two TypeScript code snippets that demonstrate how to use enums in TypeScript.

Notifications You must be signed in to change notification settings

JakubKontra/typescript-enums-better-way

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TypeScript Enum Examples

This repository contains two TypeScript code snippets that demonstrate how to use enums in TypeScript.

Compiled 01-typescript-enum.ts code

"use strict";
var Color;
(function (Color) {
    Color["Red"] = "red";
    Color["Green"] = "green";
    Color["Blue"] = "blue";
})(Color || (Color = {}));
getColor(colors.red);

Compiled 02-enum-from-const.ts code

"use strict";
const colors = {
    red: 'red',
    green: 'green',
    blue: 'blue'
};
getColor(colors.red);

Bundle size

117 bytes vs 84 bytes

About

This repository contains two TypeScript code snippets that demonstrate how to use enums in TypeScript.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published