Snippets about typescript
6 snippets
-
SNP135
Different config for dev and production in Stati
getEnv() knows which command is running. NODE_ENV doesn't.
16 lines of ts in 1 block, 12 lines of explanation with 4 notes.
#529 -
SNP106
Make some properties optional in TypeScript
Partial makes everything optional, which is rarely what you want. Here is the targeted version.
13 lines of ts in 2 blocks, 3 lines of explanation.
#B25 -
SNP098
Load a script only on some pages in Stati
Stati's TypeScript bundles with include and exclude, and how their patterns match.
19 lines of ts and eta in 2 blocks, 11 lines of explanation with 4 notes.
#42A -
SNP093
Search a Stati site in the browser
Stati writes the search index at build time. A few dozen lines of TypeScript search it.
39 lines of ts and html in 2 blocks, 11 lines of explanation with 3 notes.
#9B5 -
SNP092
Run TypeScript directly with Node
No build step, no ts-node, for scripts and quick experiments.
2 lines of sh and ts in 2 blocks, 7 lines of explanation.
#A24 -
SNP068
Exhaustive switch in TypeScript
Make the compiler complain when you add a case to a union and forget to handle it.
14 lines of ts in 1 block, 3 lines of explanation.
#B26