Snippets about typescript

6 snippets

Back to all snippets

  1. 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.

  2. 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 typescript
  3. 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.

  4. 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.

  5. 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.

  6. 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 typescript