Skip to content

Instantly share code, notes, and snippets.

View KrzysztofZawisla's full-sized avatar
🌪️
Working on own knowledge repository

Krzysztof Zawisła KrzysztofZawisla

🌪️
Working on own knowledge repository
View GitHub Profile
@KrzysztofZawisla
KrzysztofZawisla / typescript-extended-props-with-generics.tsx
Created March 24, 2022 10:52
A cheat sheet to React with TypeScript, on how to extend props with props from the usage scope.
type ComponentWithGenericPropertiesBaseWithoutGeneric = {
baseValue: string;
};
type ComponentWithGenericPropertiesBase<T> = T extends infer T
? T & ComponentWithGenericPropertiesBaseWithoutGeneric
: ComponentWithGenericPropertiesBaseWithoutGeneric;
type ComponentWithGenericPropertiesFirstUnion = {
valueFromFirstUnion: string;
{
"env": {
"browser": true,
"es2021": true,
"jest/globals": true
},
"extends": [
"plugin:testing-library/react",
"eslint:recommended",
"plugin:react/recommended",
import { app } from "electron";
const memory: number = 8192; // memory in mb
app.commandLine.appendSwitch("js-flags", `--max-old-space-size=${memory}`);
func WasmQueryOn(this js.Value, args []js.Value) interface{} {
if len(args) > 1 {
selector := args[0]
function := args[1]
if function.Type() == js.TypeFunction && selector.Type() == js.TypeString {
jsSelector := js.Global().Get("String").New(selector)
firstLetter := jsSelector.Call("substr", 0, 1)
firstLetterUpperCase := js.Global().Get("String").New(firstLetter).Call("toUpperCase")
restOfWord := jsSelector.Call("substr", 1, selector.Length()-1)
value := "on" + firstLetterUpperCase.String() + restOfWord.String()