From a9d6dd1b1b3193ef431af031e6dab67d120fce39 Mon Sep 17 00:00:00 2001 From: Matt Pocock Date: Mon, 11 Sep 2023 10:59:01 +0100 Subject: [PATCH] 2023-09-11T09:59:01.848Z --- ...4-how-enums-break-structural-typing.problem.ts | 15 +++++++++++++++ ...ow-enums-break-structural-typing.solution.1.ts | 15 +++++++++++++++ ...ow-enums-break-structural-typing.solution.2.ts | 15 +++++++++++++++ ...-how-enums-break-structural-typing.solution.ts | 0 4 files changed, 45 insertions(+) create mode 100644 src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.1.ts create mode 100644 src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.2.ts delete mode 100644 src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.ts diff --git a/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.problem.ts b/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.problem.ts index e69de29..634dc76 100644 --- a/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.problem.ts +++ b/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.problem.ts @@ -0,0 +1,15 @@ +enum LogLevel { + DEBUG = "DEBUG", + WARN = "WARN", + ERROR = "ERROR", +} + +enum LogLevel2 { + DEBUG = "DEBUG", + WARN = "WARN", + ERROR = "ERROR", +} + +function printImportant(key: LogLevel) {} + +printImportant(LogLevel2.DEBUG); diff --git a/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.1.ts b/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.1.ts new file mode 100644 index 0000000..0b0b21d --- /dev/null +++ b/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.1.ts @@ -0,0 +1,15 @@ +enum LogLevel { + DEBUG = "DEBUG", + WARN = "WARN", + ERROR = "ERROR", +} + +enum LogLevel2 { + DEBUG = "DEBUG", + WARN = "WARN", + ERROR = "ERROR", +} + +function printImportant(key: LogLevel | LogLevel2) {} + +printImportant(LogLevel2.DEBUG); diff --git a/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.2.ts b/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.2.ts new file mode 100644 index 0000000..c3ce711 --- /dev/null +++ b/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.2.ts @@ -0,0 +1,15 @@ +enum LogLevel { + DEBUG = "DEBUG", + WARN = "WARN", + ERROR = "ERROR", +} + +enum LogLevel2 { + DEBUG = "DEBUG", + WARN = "WARN", + ERROR = "ERROR", +} + +function printImportant(key: "DEBUG" | "WARN" | "ERROR") {} + +printImportant(LogLevel2.DEBUG); diff --git a/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.ts b/src/050-understanding-the-compiler/154-how-enums-break-structural-typing.solution.ts deleted file mode 100644 index e69de29..0000000