This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference types="@welldone-software/why-did-you-render" /> | |
// ^ doesn't actually do anything in some projects? | |
import React from "react"; | |
// NOTE: add `import './__wdyr-18';` to top of your entry file (e.g. `index.tsx` or `App.tsx`) to enable WDYR | |
// NOTE: to install the correct version for React 18, run `npm install @welldone-software/why-did-you-render@^8 --save-dev --save-exact` | |
// https://github.com/welldone-software/why-did-you-render/tree/version-8 | |
// https://github.com/welldone-software/why-did-you-render/tree/version-8#tracking-components |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2023 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/b1d6650475c0b30dc57eebe13d20ae37 | |
/** | |
* Type guard helper for checking if a value is truthy. mostly for use with | |
* {@link Array.prototype.filter} to clean up array types | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2023 Zach Hardesty | |
// TODO: check out https://www.totaltypescript.com/get-keys-of-an-object-where-values-are-of-a-given-type | |
/** | |
* Extracts keys of `TObj` that correspond to values that some type in the union | |
* `TTypes` can be assigned to | |
* | |
* @template TObj Object to extract keys from | |
* @template TTypes Type to check for assignability |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/81679a314603786b1ec9106ac82c3444 | |
// DEBUGGING HELP | |
// https://blog.andrewbran.ch/debugging-the-type-script-codebase/ | |
// https://www.typescriptlang.org/docs/handbook/compiler-options.html | |
// https://medium.com/jspoint/typescript-compilation-the-typescript-compiler-4cb15f7244bc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// run like this: | |
// node ./parse-vscode-profile.js "$HOME"/Downloads/profile.code-profile | |
const fs = require("fs") | |
const file = fs.openSync(process.argv[2], "r") | |
for (const line of fs.readFileSync(file, "utf8").split("\n")) { | |
const extensions = JSON.parse(JSON.parse(line).extensions) | |
const enabledExtensions = extensions.filter((extension) => !extension.disabled) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/737d914974c9ae26935a5c3fcfdc0289 | |
// TODO: write functions that mimic React for better example | |
// see the comment toward the bottom for the issue | |
type SetStateAction<S> = S | ((prevState: S) => S) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2024 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/1b5b6f6de328f1bb7c78cbe96ba5c720 | |
/** | |
* Passes thru successful test input, errors with inputs that are not equal. nice when | |
* you have a bunch of `never`s. can handle checking if things are `any` or `unknown` too. | |
* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/4b88be5dbc4ce1d00c37df0d1811c48b | |
// experiments that have thus far been unsuccessful | |
// https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f | |
// https://github.com/fightingcat/sits |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/2bc7327353adb13e7b443f8c85113ba0 | |
// eventually a solution to day 16 of Advent of Code 2021 using only the compile-time | |
// type system of TypeScript. | |
// https://adventofcode.com/2021/day/16 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// copyright 2022 Zach Hardesty | |
// want to check this out in the TypeScript playground? | |
// visit the following link to automatically see the latest version! | |
// https://www.typescriptlang.org/play?jsx=0#gist/65ff817661487a3bfb02a5c698825df9 | |
/** test type of obj w nesting */ | |
type T000 = { | |
a1: { | |
b1: boolean |
NewerOlder