This is a script to replace placeholders like {name} in a Word document with their values as defined in an Excel spreadsheet.
- Save
replace.ps1below somewhere on your machine. - Create a Word document with your message, for example:
Hello {Name},
| // ==UserScript== | |
| // @name Block GIF avatars | |
| // @namespace https://gerritbirkeland.com/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author You | |
| // @match https://discord.com/* | |
| // @grant none | |
| // ==/UserScript== |
| //@ts-check | |
| 'use strict'; | |
| const fs = require('fs'); | |
| const ts = require('typescript'); | |
| const path = require('path'); | |
| const Module = require('module'); | |
| // These are declared as globals | |
| const SKIP_MODULES = new Set([ |
| import { ok as assert } from 'assert' | |
| import { readFile, writeFile } from 'fs/promises' | |
| import { getHighlighter, getTheme } from 'shiki' | |
| // This is bad... but Shiki doesn't export it from the root. | |
| import { Highlighter } from 'shiki/dist/highlighter' | |
| import { TLang } from 'shiki-languages' | |
| import { TTheme } from 'shiki-themes' | |
| import { createElement, JSX } from 'preact' |
The different subtype error is usually caused by two mistakes:
function broke<T extends string>(x: T = "error"): T { return x }
// ^^^^^^^^^^^^^^
// Type 'string' is not assignable to type 'T'.
// 'string' is assignable to the constraint of type 'T', but
// 'T' could be instantiated with a different subtype of
// constraint 'string'.| // @ts-check | |
| const fs = require("fs"); | |
| const http = require("http"); | |
| const esbuild = require("esbuild"); | |
| const { join } = require("path"); | |
| // ===== Configuration ===== | |
| const port = parseInt(process.argv[process.argv.indexOf("--port") + 1]) || 8080; |
| // @ts-check | |
| /** | |
| * typedoc-plugin-not-exported | |
| * TypeDoc plugin that forces inclusion of non-exported symbols (variables) | |
| * Originally from https://github.com/TypeStrong/typedoc/issues/1474#issuecomment-766178261 | |
| * https://github.com/tomchen/typedoc-plugin-not-exported | |
| * CC0 | |
| */ | |
| const { |
| function aggregate<T>(arr: T[], fn: (item: T) => number) { | |
| return arr.reduce((sum, it) => sum + fn(it), 0); | |
| } | |
| function aggregateWithJoiner<T>(arr: T[], fn: (item: T) => number, joiner: string) { | |
| return arr.reduce((sum, it) => sum + fn(it), 0) + (arr.length - 1) * joiner.length; | |
| } | |
| // Used to check if we should split a union into multiple lines. | |
| export function estimatePrintWidth(type: Type): number { | |
| return type.visit({ |
+++ title = "TypeScript - Type Safe Plugins" date = 2024-10-14 +++
A recent question in the TypeScript Discord needs more space than is available there. It happens to be a pretty good question for providing a walkthrough for how I create complex systems, so I am roughly reproducing it here to be able to reference it in the future.