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
const chars = [ | |
'亜', | |
'哀', | |
'挨', | |
'愛', | |
'曖', | |
'悪', | |
'握', | |
'圧', | |
'扱', |
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
#!/bin/bash | |
negative_state=$(cat <<- END | |
{ | |
"state": "failure", | |
"context": "poi", | |
"description": "hi" | |
} | |
END | |
) | |
echo "$negative_state" |
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
module.exports = { | |
trailingComma: 'all', | |
tabWidth: 2, | |
semi: false, | |
singleQuote: true, | |
printWidth: 100, | |
} |
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
module.exports = { | |
root: true, | |
env: { | |
browser: true, | |
node: true, | |
}, | |
extends: [ | |
'@nuxtjs/eslint-config-typescript', | |
'@vue/prettier', | |
'@vue/prettier/@typescript-eslint', |
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
const x: { x: number } | null = { x: 10 } | |
console.log(x.x) // no errors | |
const y: { x: number } | null = null | |
console.log(y.x) // 2531: Object is possibly 'null'. |
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
/** | |
* The type 'true' means a proof is satisfied. | |
* The type 'never' means a proof is not satisfied. | |
*/ | |
// Basic of this idea. | |
type AWrongProof = { x: number } extends { x: string } ? true : never | |
// Compile NG |
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
/** | |
* Proves that A and B is the same types. | |
*/ | |
export type Equal<A, B> = A extends B ? (B extends A ? true : never) : never | |
/** | |
* Makes all fields of A to `<its-type> | null`. | |
*/ | |
export type Nullable<A extends Record<string, unknown>> = { [K in keyof A]: A[K] | null } |
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
/** | |
* Proves that A and B is the same types. | |
*/ | |
export type Equal<A, B> = A extends B ? (B extends A ? true : never) : never | |
/** | |
* Makes all fields of A to `<its-type> | null`. | |
*/ | |
export type Nullable<A extends Record<string, unknown>> = { [K in keyof A]: A[K] | null } |
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
import axios from 'axios' | |
function isThatArray<T>(x: unknown, p: (a: unknown) => a is T): x is Array<T> { | |
return Array.isArray(x) && x.every(p) | |
} | |
function isString(x: unknown): x is string { | |
return typeof x === 'string' | |
} |
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
{-# LANGUAGE TypeSynonymInstances #-} | |
{-# LANGUAGE FlexibleInstances #-} | |
newtype Fix f = Fix | |
{ unFix :: f (Fix f) | |
} | |
cata :: Functor f => (f a -> a) -> Fix f -> a | |
cata f (Fix x) = f $ fmap (cata f) x |