From a9aedc4902a9813eaff21d51cd679f33e33687a0 Mon Sep 17 00:00:00 2001 From: Thomas Rittson Date: Wed, 25 Jun 2025 11:37:01 +1000 Subject: [PATCH 1/3] Fix typo in enum like code sample --- docs/architecture/adr/0025-ts-deprecate-enums.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/architecture/adr/0025-ts-deprecate-enums.md b/docs/architecture/adr/0025-ts-deprecate-enums.md index d37bc912f..aa310f41c 100644 --- a/docs/architecture/adr/0025-ts-deprecate-enums.md +++ b/docs/architecture/adr/0025-ts-deprecate-enums.md @@ -43,7 +43,7 @@ const CipherType = Object.freeze({ SshKey: 5, } as const); -export type CipherType = _CipherType[keyof typeof CipherType]; +export type CipherType = (typeof CipherType)[keyof typeof CipherType]; ``` This code creates a `type CipherType` that allows arguments and variables to be typed similarly to From 9cf348e040365d0583577c31a6595f068244acec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=20Audrey=20=E2=9C=A8?= Date: Wed, 25 Jun 2025 07:33:03 -0400 Subject: [PATCH 2/3] additional corrections --- docs/architecture/adr/0025-ts-deprecate-enums.md | 2 +- docs/contributing/code-style/angular.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/architecture/adr/0025-ts-deprecate-enums.md b/docs/architecture/adr/0025-ts-deprecate-enums.md index aa310f41c..0b8b92fcd 100644 --- a/docs/architecture/adr/0025-ts-deprecate-enums.md +++ b/docs/architecture/adr/0025-ts-deprecate-enums.md @@ -35,7 +35,7 @@ In most cases, enums are unnecessary. A readonly (`as const`) object coupled wit avoids both code generation and type inconsistencies. ```ts -const CipherType = Object.freeze({ +export const CipherType = Object.freeze({ Login: 1, SecureNote: 2, Card: 3, diff --git a/docs/contributing/code-style/angular.md b/docs/contributing/code-style/angular.md index 0f7322978..fb9c0a2fa 100644 --- a/docs/contributing/code-style/angular.md +++ b/docs/contributing/code-style/angular.md @@ -206,7 +206,7 @@ property from your component: ```ts // given: -const EnumLike = { Some = "some", Value: "value" }; +const EnumLike = { Some: "some", Value: "value" }; type EnumLike = EnumLike[keyof typeof EnumLike]; // add the input: From c59d178539fc9126f15a5c20df51d2be9dc46189 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=9C=A8=20Audrey=20=E2=9C=A8?= Date: Wed, 25 Jun 2025 10:28:13 -0400 Subject: [PATCH 3/3] align warning with contributors docs --- docs/architecture/adr/0025-ts-deprecate-enums.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/architecture/adr/0025-ts-deprecate-enums.md b/docs/architecture/adr/0025-ts-deprecate-enums.md index 0b8b92fcd..5cd29c4d1 100644 --- a/docs/architecture/adr/0025-ts-deprecate-enums.md +++ b/docs/architecture/adr/0025-ts-deprecate-enums.md @@ -62,6 +62,9 @@ let value: CipherType = CipherType.Login; // ❌ Do not: use type inference const array = [CipherType.Login]; // infers `number[]` let value = CipherType.Login; // infers `1` + +// ❌ Do not: use type assertions +let value = CipherType.Login as CipherType; // this operation is unsafe ``` :::