From 2035fc64e0d6abbe8d7eb64823054f32178cced1 Mon Sep 17 00:00:00 2001 From: Andrew Branch Date: Wed, 27 Mar 2024 15:54:33 -0700 Subject: [PATCH] Update test --- ...oInitializerFollowsNonLiteralInitializer.errors.txt | 10 +++++++--- .../enumNoInitializerFollowsNonLiteralInitializer.js | 10 ++++++---- .../enumNoInitializerFollowsNonLiteralInitializer.ts | 5 +++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.errors.txt b/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.errors.txt index afe403e720923..3b137187d1478 100644 --- a/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.errors.txt +++ b/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.errors.txt @@ -1,16 +1,22 @@ bad.ts(4,5): error TS18056: Enum member following a non-literal numeric member must have an initializer when 'isolatedModules' is enabled. +bad.ts(7,5): error TS1061: Enum member must have initializer. ==== ./helpers.ts (0 errors) ==== export const foo = 2; -==== ./bad.ts (1 errors) ==== +==== ./bad.ts (2 errors) ==== import { foo } from "./helpers"; enum A { a = foo, b, ~ !!! error TS18056: Enum member following a non-literal numeric member must have an initializer when 'isolatedModules' is enabled. + c = 10, + d = (c)! satisfies number as any, + e, + ~ +!!! error TS1061: Enum member must have initializer. } ==== ./good.ts (0 errors) ==== @@ -38,7 +44,5 @@ bad.ts(4,5): error TS18056: Enum member following a non-literal numeric member m d, e = d | b, f, - g = (f | a)! satisfies number as any, - h, } \ No newline at end of file diff --git a/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.js b/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.js index 2c1d8ef4c414c..bc21c531709a1 100644 --- a/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.js +++ b/tests/baselines/reference/enumNoInitializerFollowsNonLiteralInitializer.js @@ -8,6 +8,9 @@ import { foo } from "./helpers"; enum A { a = foo, b, + c = 10, + d = (c)! satisfies number as any, + e, } //// [good.ts] @@ -35,8 +38,6 @@ enum E { d, e = d | b, f, - g = (f | a)! satisfies number as any, - h, } @@ -53,6 +54,9 @@ var A; (function (A) { A[A["a"] = 2] = "a"; A[A["b"] = 3] = "b"; + A[A["c"] = 10] = "c"; + A[A["d"] = (A.c)] = "d"; + A[A["e"] = void 0] = "e"; })(A || (A = {})); //// [good.js] "use strict"; @@ -86,6 +90,4 @@ var E; E[E["d"] = 1] = "d"; E[E["e"] = 1] = "e"; E[E["f"] = 2] = "f"; - E[E["g"] = 2] = "g"; - E[E["h"] = 3] = "h"; })(E || (E = {})); diff --git a/tests/cases/compiler/enumNoInitializerFollowsNonLiteralInitializer.ts b/tests/cases/compiler/enumNoInitializerFollowsNonLiteralInitializer.ts index 1a8876bf5adab..72cd4af5e8ac5 100644 --- a/tests/cases/compiler/enumNoInitializerFollowsNonLiteralInitializer.ts +++ b/tests/cases/compiler/enumNoInitializerFollowsNonLiteralInitializer.ts @@ -9,6 +9,9 @@ import { foo } from "./helpers"; enum A { a = foo, b, + c = 10, + d = (c)! satisfies number as any, + e, } // @filename: ./good.ts @@ -36,6 +39,4 @@ enum E { d, e = d | b, f, - g = (f | a)! satisfies number as any, - h, }