Skip to content

Commit e864c6d

Browse files
committed
fix capitalizaton
1 parent 22d9b56 commit e864c6d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

docs/architecture/adr/0025-ts-deprecate-enums.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ In most cases, enums are unnecessary. A readonly (`as const`) object coupled wit
3535
avoids both code generation and type inconsistencies.
3636

3737
```ts
38-
// declare the raw data and reduce repetition with an internal type
3938
const CipherType = Object.freeze({
4039
Login: 1,
4140
SecureNote: 2,
@@ -44,7 +43,6 @@ const CipherType = Object.freeze({
4443
SshKey: 5,
4544
} as const);
4645

47-
// derive the enum-like type from the raw data
4846
export type CipherType = _CipherType[keyof typeof CipherType];
4947
```
5048

@@ -53,7 +51,7 @@ an enum.
5351

5452
:::warning
5553

56-
Unlike an enum, typescript lifts the type of the members of `const CipherType` to `number`. Code
54+
Unlike an enum, TypeScript lifts the type of the members of `const CipherType` to `number`. Code
5755
like the following requires you explicitly type your variables:
5856

5957
```ts
@@ -75,7 +73,7 @@ let value = CipherType.Login; // infers `1`
7573
- **Deprecate enum use** - Allow enums to exist for historic or technical purposes, but prohibit the
7674
introduction of new ones. Reduce the lint to a "warning" and allow the lint to be disabled.
7775
- **Eliminate enum use** - This is the current state of affairs. Prohibit the introduction of any
78-
new enum and replace all enums in the codebase with typescript objects. Prohibit disabling of the
76+
new enum and replace all enums in the codebase with TypeScript objects. Prohibit disabling of the
7977
lint.
8078

8179
## Decision Outcome
@@ -85,6 +83,8 @@ Chosen option: **Deprecate enum use**
8583
### Positive Consequences
8684

8785
- Allows for cases where autogenerated code introduces an enum by necessity.
86+
- Literals (e.g. `1`) convert to the enum-like type with full type safety.
87+
- Works with mapped types such as `Record<T, U>` and discriminated unions.
8888
- Developers receive a warning in their IDE to discourage new enums.
8989
- The warning can direct them to our contributing docs, where they can learn typesafe alternatives.
9090
- Our compiled code size decreases when enums are replaced.
@@ -94,6 +94,7 @@ Chosen option: **Deprecate enum use**
9494

9595
- Unnecessary usage may persist indefinitely on teams carrying a high tech debt.
9696
- The lint increased the number of FIXME comments in the code by about 10%.
97+
- Enum-likes cannot be referenced by angular templates
9798

9899
### Plan
99100

docs/contributing/code-style/enums.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type CipherContent =
6060
6161
:::warning
6262
63-
Unlike an enum, typescript lifts the type of the members of `const CipherType` to `number`. Code
63+
Unlike an enum, TypeScript lifts the type of the members of `const CipherType` to `number`. Code
6464
like the following requires you explicitly type your variables:
6565
6666
```ts

0 commit comments

Comments
 (0)