From 6ae8af932d44e06848da801ea415d13e42f77cba Mon Sep 17 00:00:00 2001 From: "Harry Ross [SSW]" Date: Wed, 27 Mar 2024 09:39:42 +1100 Subject: [PATCH] =?UTF-8?q?XS=E2=9C=94=20=E2=97=BE=20Typescript=20Enums=20?= =?UTF-8?q?Rule=20(#8193)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * added base rule * added bits to include object const assertions * Added image of vscode use * added vscode screenshots for object const assertions * bit of content cleanup * added intro sentence * added correct timestamp * Auto-fix Markdown files * Update rules/typescript-enums/rule.md Co-authored-by: Brady Stroud [SSW] * Auto-fix Markdown files * Update rules/typescript-enums/rule.md Co-authored-by: Brady Stroud [SSW] * Update rules/typescript-enums/rule.md Co-authored-by: Brady Stroud [SSW] * Update rules/typescript-enums/rule.md Co-authored-by: Brady Stroud [SSW] * Update rules/typescript-enums/rule.md Co-authored-by: Brady Stroud [SSW] * Auto-fix Markdown files * Update rules/typescript-enums/rule.md Co-authored-by: Jeoffrey Fischer [SSW] <106663901+jeoffreyfischer@users.noreply.github.com> * Auto-fix Markdown files * made jeoffrey's requested changes * requested changes from jeoffrey * Auto-fix Markdown files * changed title to be more readable * Update rules/typescript-enums/rule.md Formatted enum Co-authored-by: Matt Wicks [SSW] * Update rules/typescript-enums/rule.md Reworded phrasing Co-authored-by: Matt Wicks [SSW] * added point about consts * added headings + good and bad examples * Auto-fix Markdown files * Added sentence at bottom for usage of when an enum is preferred * added single source of truth part to sentence --------- Co-authored-by: github-actions[bot] Co-authored-by: Tiago Araújo [SSW] Co-authored-by: Brady Stroud [SSW] Co-authored-by: Jeoffrey Fischer [SSW] <106663901+jeoffreyfischer@users.noreply.github.com> Co-authored-by: Matt Wicks [SSW] --- .../rules-to-better-typescript.md | 1 + rules/typescript-enums/icon-vscode-sense.png | Bin 0 -> 15010 bytes .../typescript-enums/iconkey-vscode-sense.png | Bin 0 -> 10877 bytes rules/typescript-enums/rule.md | 127 ++++++++++++++++++ .../vscode-intellisense-array2.png | Bin 0 -> 9796 bytes 5 files changed, 128 insertions(+) create mode 100644 rules/typescript-enums/icon-vscode-sense.png create mode 100644 rules/typescript-enums/iconkey-vscode-sense.png create mode 100644 rules/typescript-enums/rule.md create mode 100644 rules/typescript-enums/vscode-intellisense-array2.png diff --git a/categories/software-engineering/rules-to-better-typescript.md b/categories/software-engineering/rules-to-better-typescript.md index 9e27c392b65..7e904c33089 100644 --- a/categories/software-engineering/rules-to-better-typescript.md +++ b/categories/software-engineering/rules-to-better-typescript.md @@ -6,6 +6,7 @@ uri: rules-to-better-typescript index: - avoid-using-any - describe-types-sparsely +- typescript-enums - follow-good-object-oriented-design-patterns - good-typescript-configuration - only-export-what-is-necessary diff --git a/rules/typescript-enums/icon-vscode-sense.png b/rules/typescript-enums/icon-vscode-sense.png new file mode 100644 index 0000000000000000000000000000000000000000..a983ea3a807045211952330bb36d1eaab8879dc0 GIT binary patch literal 15010 zcmbWebyQqk@GS@gLI@Dtp&<|~1b2s^K?A|9ad&rjPlCI<26qb(+}$m>H%@m?lkdGZ zzkg<}nK^4gpYGdSj#TYadsp3vuL@G=Z;9W+!NH+_krr2mgL?&m^&Q{5hW$Qz{q`F6 z0`H_O^%<^eob(X(2GLAZUK9?lHV*aK015UU#a>#|2@dXE-^&mDpk0YE92_6_7jaP) zcfHd!WOv-Th1VAZ(-gr;lh_;-)8g@8KOl-0gv3(Fr%~J&(_NJM%iw(V#6l{dm;V|` z@kZvH?u~L`2?ZfSz$7+;?B}Ep-cDzuH0fhS1PGm7`>C|-Zl-QDZ9#uW1@Bf#_lA=_ z-%$S7JSq1$e6g|qwJDtN0O9}L{WPTl%?m*#v=aZXftn5D{?Ene|NDFYpSm*-CaJOa z?iS3mOn=dwF7!T~-Lk5Yc!mE;j1|&21FBT63pJB~|4QXObT1!h@y5+#M>sLK?d()q zx{-D%-#=Ee#Z%cs+?!iLk0*y8b1njW~V+l$KW0Hy;s#;yDk6lY=uYO4flR*6qXC94apbe+y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DCE*~bW!YX_cCW`%HJ+A-enZRO4(#~0# z6akALX^~$|o$dwEzmY6ci6MNb?1F*b0YuV`!+LRY@zrb<7`sR@`yDwsc>|*uElm7- z1#`#mf^sls;cQUmw=5lUXV4c~+Ra{AP?9Sr1}iJE&JUS3gtU8H+}yy*>ZId+ul_}Q zY(1c0i!V3Hn~eo!1JGN9}tqXPnA0oF@c{1MUoeLr=f#x91HU$-{&i5!+#r=%QK z`Cr`dUzwoN?MrRZzm^9jgt7Ynnj*^!!DoWiBHBATa{Twy$$`@Mu93ZSC+!!8t!o<+ zoU4K5W)$^enBf4thc+FEP}9r#IlZ^h%|NGK^ucl8kyY#8WxDdAjh!pEmS-Q^k^c%t zT`2QZ+6a8fdC45NL-u9MJ^oUiNm0_!3@pn28$s%q>8B_!{LhKQdsy~|ADMJJO-~~F zUTPA>{vYZl*@}SEPld(M|5G&izh@GAN&DXfJp*A$oc|wPLwG0#hqMe$WQR@??7337 NFA@skRiE_(|1S^g!omOm literal 0 HcmV?d00001 diff --git a/rules/typescript-enums/iconkey-vscode-sense.png b/rules/typescript-enums/iconkey-vscode-sense.png new file mode 100644 index 0000000000000000000000000000000000000000..8e7b91cca8f85076c0a649ceeb7122b2635e3196 GIT binary patch literal 10877 zcmbt)1yEeU^Cpr&a0`nq5ZobHa0p>>cXtWFEx79v+zA@of_rdxcV{6axVzp$e*gbn z)zwwq)lJpzzBfB>reAkY&)45fsDhk08Zsd=3=9mKqy$I_2IiG4^xEzX0`z;2BT^Xp z1M8?H{t2dR6u1MudG%RX7Ft;ug>rBB8hVdpC!y&G1B2f6{DJMWEi{3Fp~sd439Gp3 z9jqYfsHol{9+RS?mJt203JTu%l-LkBRAQU|M=QTEue`1~alvdWHZguyf2c)D+UB8;w-4@(H*48bI{ zjF&auX9em}q`G7ZR#!ML$yw=gp?KAf%L>B3x2|=N;dwmEW_>f;c}2f=66w07ouq9$ zbyQWq_}&Y0wK5E7!7C}>YdrZd{>5;Rq4MJ-#cOq(nmSF3*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o$8)`)oMVGb5PPGGU+p;w0|q&Hrg>1ejCtY2Z0kz6=?d{2}&07X+0%W8^WU5 z09N*NcN-ioyUqI;w9WoU?;B9^0h&e5|KlLY>3#mgL_JTGSI^r0SAH5i+vlb9Bmciw z(`%?DB3)iOFOod_36|>HlSUm+L9XZJxzJx%Ucz6UiOV|brF;5s*E-CCnW-=IL1XAS>a?C|qj$V@Ln1%*{onldb@?&-pq6)`iTo}6TlPERi- zrh0xLyNWXZ_qDsnk1uh-4M2i`{=#fzvNl`ga*(U@4{{d*QgtPzv literal 0 HcmV?d00001 diff --git a/rules/typescript-enums/rule.md b/rules/typescript-enums/rule.md new file mode 100644 index 00000000000..02cbb8859e1 --- /dev/null +++ b/rules/typescript-enums/rule.md @@ -0,0 +1,127 @@ +--- +type: rule +title: Do you know why to use const assertions instead of TypeScript enums? +uri: typescript-enums +authors: + - title: Harry Ross + url: https://ssw.com.au/people/harry-ross +related: + - use-enums-instead-of-hard-coded-strings +created: 2024-03-19T21:39:38.906Z +archivedreason: null +guid: ba19be99-354d-44b2-a2da-4131cc660f18 +--- +It's super important to ensure that [magic strings are not used in your codebase](https://www.ssw.com.au/rules/use-enums-instead-of-hard-coded-strings/). Typically, we would use constant values or enums to solve this problem, but this may not be applicable when using TypeScript. You might expect TypeScript enums to function like strongly typed languages like C# but often this is not the case. + + + +`youtube: jjMbPt_H3RQ` +**Video: Enums considered harmful (9 min)** + +While TypeScript enums provide a lot of useful type safety at runtime, it's very important to consider that there may be cleaner options. + +## Numerical Enums + +When you define an enum like this: + +```ts +enum Fruits { + Apple, + Banana, + Cherry +} +``` + +When compiled to JavaScript, it looks like: + +```js +var Fruits; +(function (Fruits) { + Fruits[Fruits["Apple"] = 0] = "Apple"; + Fruits[Fruits["Banana"] = 1] = "Banana"; + Fruits[Fruits["Cherry"] = 2] = "Cherry"; +})(Fruits || (Fruits = {})); +``` + +However, this makes it hard to loop over the keys of the enum, as when you run `Object.keys(Fruits)` you would get the following array returned: + +::: bad + +```ts +["0", "1", "2", "Apple", "Banana", "Cherry"] +``` + +**Bad Example - an irritating DX, instead of returning just the values of the enum** +::: + +Instead, a much cleaner option is by using [const assertions](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions). With const assertions we can be sure the code is using the string values we want: + +```ts +const fruits = ["Apple", "Banana", "Cherry"] as const; +``` + +Now, if we look into the content of the shapes array using: + +```ts +type Fruit = typeof fruits[number]; +``` + +We can construct this type from the above array, which is equivalent to: + +::: good + +```ts +type Fruit = "Apple" | "Banana" | "Cherry"; +``` + +**Good Example - a much cleaner DX** +::: + +This makes it super easy to loop over keys within a union type. This also allows us to be able to pass `"Apple"` into a function that takes `Fruit` as an argument. We get super useful feedback from our code editor - the same as a typical TypeScript union type from VSCode from the `Fruit` union type: + +![Figure: Working VSCode Intellisense that works with all const assertions](vscode-intellisense-array2.png) + +## String Enums + +::: bad + +```tsx +enum Icon { + sun = "sun", + moon = "moon" +} + +const icons: Record = { + sun: "sun_12345.jpg", + moon: "moon_543212.jpg" +}; +``` + +**Bad Example - duplication of key values where it is not needed** +::: + +This is problematic, as it provides us no useful type hints for object values, as object values are typed as `string`, and there is an unecessary duplication of object keys. For cases like this with a single source of truth (i.e. the `icons` object), we can use const assertions, similiar to above with objects: + +::: good + +```tsx +const icons = { + sun: "sun_12345.jpg", + moon: "moon_543212.jpg", +} as const; + +type IconKey = keyof typeof icons; // "sun" | "moon" union type + +type Icon = (typeof icons)[IconKey]; // "sun_12345.jpg" | "moon_543212.jpg" union type +``` + +**Good Example - a much cleaner DX with a single source of truth in the `as const` object** +::: + +Similar to the array const assertion above, these also provide useful type hints in your code editor: + +![Figure: Using the Icon type from above](icon-vscode-sense.png) + +![Figure: The IconKey type from above](iconkey-vscode-sense.png) + +Remember, it's important to assess on a case-by-case basis when you are writing code to determine whether a const assertion can be used instead of an enum. For example, it's important when dealing with object values you don't want to overlap (i.e. `Icon1`, `Icon2` both with a `moon` key but with different moon images) to opt for enums. However, using const assertions will likely lead to better DX (Developer eXperience) in most cases. diff --git a/rules/typescript-enums/vscode-intellisense-array2.png b/rules/typescript-enums/vscode-intellisense-array2.png new file mode 100644 index 0000000000000000000000000000000000000000..2ff89b40772b759b17130a5ad9a939ddc82819d2 GIT binary patch literal 9796 zcmbVy2UJsAw{9%xK@V~~fCva!4j>?+^dg`K5drC)P?QcKp@R^Lih!Vi^xi~jr~(Ou zsz~o8AS9tk2{oaGNCM>UoPYddy#K!O#(4LxF_OKrvR9jHu5W(dOrrF3)LAZYUjTtX zEE-QA8-PG(P{4igZ|8vb0D96h;Bv~_K>cq}<7@2ReO+l6F6=OZlMQGA}8tHHNX|d zWj)-z2+!SX86sE`elMUk57!5Utxv=}xC_h#)E-ccB{)&c^t zo4o}yt`A?UH!$W5Vt=_di8Hxv+BbXV)x}|4z(pJu3AI2oo@O$}xcb(^DKdqdSQqe6 z=m*?sMvDs%zKJoedF{9U?}{r|Q$<(sjTwq0$T6u?5z6D?XvB53XqN4+0VO}&XaIQ% zXnDxBAQLHKjRjW)?KdjZcOkOR(cMC~d^3ZO1|Wrj(yDm4!@9K6`zr9g&SugcWr=T* z-Hu`t6Rc%e)xI}T^rHpP`O-y#c>}ccr|ys* ze#&M_4Jn{&M64*L&6Tc3FI-?jLY?qI6~`TmxWGDZ%%9q18S1FTeRsthL0*1e;jd=3 zI8Vm-No16RoMPogeH1fiV?kkhoSrn&!KvHx_{&KNoV49lK<#WH*etc*^W_2my3^KX zY2m9!!z-4KT_!jV>rr10TVxL^~edwJ`v&Ks{EML=F^T`3SXsFni!R^ ziOPl|?w?U8g=V(F^D)!J&^01R2RwlHs%$7;$E&P0dxY?~HY}+lu zFRw)C<5+Tv1`Fd!hckMwnOZ8CO)&~{) z>-B(HdN_xwJh0`Tnv_RseJf(&;N8bYQ9p<1Mb29T#nRHS_o$tq8kfo5YN9tz1*aTa zyWT!?23GPc^kv;Q<=Ao0f!USE|LTbK4a3di&xj_8I*_dSs(Kr+sTsYewa~yb5i^R~tj1_8X5L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