Skip to content

Instantly share code, notes, and snippets.

@VanTanev
VanTanev / .eslintrc.json
Last active August 22, 2019 14:32
base husky + prettier + eslintconfig
{
"extends": [
"react-app",
"plugin:@typescript-eslint/recommended",
"plugin:jest/recommended",
"prettier",
"prettier/react",
"prettier/@typescript-eslint"
],
"plugins": ["jest"]
@VanTanev
VanTanev / io-ts-stringify.ts
Last active June 29, 2020 11:39
Extract static type strings from io-ts definitions
import * as t from 'io-ts'
import * as gen from 'io-ts-codegen'
import { NullableType } from 'codecs/util/nullable'
export function stringifyNaive(identifier: string, codec: t.Any): string {
return `type ${identifier} = ${codec.name}`
}
export function stringifyFull(identifier: string, codec: t.Any): string {
return `type ${identifier} = ${gen.printStatic(getType(codec))}`
@VanTanev
VanTanev / preact.config.js
Created November 7, 2020 11:09
Enable CRA-like environment variable passing in preact-cli
import webpack from 'webpack'
export default {
/**
* Function that mutates the original webpack config.
* Supports asynchronous changes when a promise is returned (or it's an async function).
*
* @param {object} config - original webpack config.
* @param {object} env - options passed to the CLI.
* @param {WebpackConfigHelpers} helpers - object with useful helpers for working with the webpack config.
import { XstateInspectLoader } from 'shared/util/XstateInspectLoader'
const App = () => {
<XstateInspectLoader>
// rest of app goes here
</XstateInspectLoader>
}
@VanTanev
VanTanev / README.md
Created May 2, 2023 13:01
A github workflow to track progress of convertion JavaScript to TypeScript.

A github workflow to track the progress of converting JavaScript to TypeScript.

Last year, we migrated a large project form JS to TS. We did this with ts-migrate, and we renamed all instances of any to $TSFixMe, to differentiate them from real uses of any.

Tracking the convertion over time

In order to see our progress on removing $TSFixMe, we build the a github workflow that adds comments to PRs with our progress, eg:

image