Skip to content

Instantly share code, notes, and snippets.

Avatar

Henning Dieterichs hediet

View GitHub Profile
@hediet
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
hediet / demo.md
Last active Jun 15, 2020
Avoid String Ids In Dependency Injection
View demo.md

Avoid String Ids In Dependency Injection

Option 1: String Ids

const myService = "MyService";

interface MyService {
    doSth(): void;
}
@hediet
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
hediet / feedback.md
Last active May 11, 2020
Binary Custom Editor API Feedback
View feedback.md

Blocker

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
hediet / after.ts
Created Apr 3, 2020
Mobx Complex Observable Example
View after.ts
type State = { kind: 'loading' } | { kind: 'loaded'; service: unknown };
@injectable()
class LoadServiceModel {
constructor(
@injectProps()
private readonly props: {
service: ServiceId<unknown>;
module?: Module;
},
@hediet
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(
tsConfigSearchPath,
ts.sys.fileExists,
"tsconfig.json"
);
View PatternMatching.ts
import { hotClass, registerUpdateReconciler } from "@hediet/node-reload";
import { ts, Node, SyntaxKind, TypeGuards, Identifier } from "ts-morph";
registerUpdateReconciler(module);
import { registerAll } from "C:\\Users\\Henning\\Desktop\\playground\\vscode-debug-visualizer\\data-extraction";
registerAll();
@hotClass(module)
export class PatternMatchMain {
View I18n.ts
interface FormatDescriptor {
id: string;
defaultTemplate?: string;
}
export type Formatted =
| { kind: 'text'; value: string }
| { kind: 'sequence'; items: Formatted[] }
| { kind: 'object'; items: Record<string, Formatted> };
@hediet
hediet / types.ts
Created Jul 23, 2019
DestructureTuple & DeepSelect
View types.ts
export type DestructureTuple<T extends any[]> = T extends []
? false
: ((...tuple: T) => void) extends ((
first: infer TFirst,
...rest: infer TRest
) => void)
? { first: TFirst; rest: TRest }
: false;
View types.ts
import * as remarkAbstract from "remark";
interface Position {}
interface Node<T extends string = string> {
position: Position;
type: T;
}
interface NodeList<T extends string = string, TItem extends Node = Node>
You can’t perform that action at this time.