Skip to content

Instantly share code, notes, and snippets.


Henning Dieterichs hediet

View GitHub Profile
hediet /
Last active Aug 12, 2022
Proof that TypeScript's Type System is Turing Complete
type StringBool = "true"|"false";

interface AnyNumber { prev?: any, isZero: StringBool };
interface PositiveNumber { prev: any, isZero: "false" };

type IsZero<TNumber extends AnyNumber> = TNumber["isZero"];
type Next<TNumber extends AnyNumber> = { prev: TNumber, isZero: "false" };
type Prev<TNumber extends PositiveNumber> = TNumber["prev"];
hediet /
Created Mar 9, 2021
Rust Sqlx Crazyness
use std::{marker::PhantomData, path::PathBuf};
use sqlx::{sqlite::SqliteConnectOptions, Error};
use sqlx::{Connection, Sqlite, Transaction};
use sqlx::{Executor, SqliteConnection};
pub struct DbFactory {
conn: SqliteConnection,
hediet / main.ts
Created Jun 15, 2020
Dynamic Translation
View main.ts
* Renders a translation that cannot be extracted statically.
* Avoid using this component as much as possible!
export class TransMsgDynamic extends React.Component<{
keyAndDefaultTranslation: string;
* A static id that represents the pool of all possible keys.
* If this id is not used in the code base anymore,
hediet /
Last active Jun 15, 2020
Avoid String Ids In Dependency Injection

Avoid String Ids In Dependency Injection

Option 1: String Ids

const myService = "MyService";

interface MyService {
    doSth(): void;
hediet / types.ts
Created Jun 9, 2020
JSON Schema TypeScript Types
View types.ts
export type JsonSchema =
| NumericJsonSchema
| StringJsonSchema
| ArrayJsonSchema
| ObjectJsonSchema
| JsonSchemaReference;
export interface JsonSchemaReference {
$ref: string;
hediet /
Last active May 11, 2020
Binary Custom Editor API Feedback


This issue is a blocker for the .drawio.png feature. This is my context. I hope something can be done there ;)

Confusion Points

  1. Default Generic Type Argument

I have to admit, I failed to recognize that CustomEditorProvider is generic when I exploratively implemented my first prototype.

hediet / after.ts
Created Apr 3, 2020
Mobx Complex Observable Example
View after.ts
type State = { kind: 'loading' } | { kind: 'loaded'; service: unknown };
class LoadServiceModel {
private readonly props: {
service: ServiceId<unknown>;
module?: Module;
hediet / WebBrowserIE11Fix.cs
Created Aug 17, 2016
A fix that enables IE11 for the WPF browser control.
View WebBrowserIE11Fix.cs
internal static class WebBrowserIE11Fix
public static void SetIE11KeyforWebBrowserControl(string processPath = null)
if (processPath == null)
processPath = Process.GetCurrentProcess().ProcessName + ".exe";
RegistryKey Regkey = null;
View PatternMatching.ts
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
import { ts, Node, SyntaxKind, TypeGuards, Identifier } from "ts-morph";
import { registerAll } from "C:\\Users\\Henning\\Desktop\\playground\\vscode-debug-visualizer\\data-extraction";
export class PatternMatchMain {
hediet / createProgram.ts
Created Sep 11, 2019
createProgram from tsConfigSearchPath
View createProgram.ts
import * as ts from "typescript";
import { dirname, resolve } from "path";
export function createProgram(tsConfigSearchPath: string): ts.Program {
const configPath = ts.findConfigFile(