Skip to content

Instantly share code, notes, and snippets.

View hannahpun's full-sized avatar

hannahpun hannahpun

View GitHub Profile
@hannahpun
hannahpun / install-all-deps.sh
Last active September 16, 2022 00:24
install-all-deps.sh
#!/bin/bash
# This script install all npm dependencies for every sub projects.
(cd web && npm ci) &&
(cd e2e && npm ci)
(cd design-system && npm ci)
Item Taiwan U.S.A
第一次產檢週數 隨意 八週後
超音波次數 每次都照 三次 (w12 /w20/ w36)
Targaryen Daenerys Targaryen Dragonstone
Greyjoy Pyke Euron Greyjoy
import { createStitches } from '@stitches/react';
export const {
styled,
css,
globalCss,
keyframes,
getCssText,
theme,
createTheme,
@hannahpun
hannahpun / migrate-ts.sh
Created June 17, 2021 00:24
migrate-ts.sh
#!/bin/bash -x
branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
project="$1"
folder="$2"
glob="$2/**/*.{ts,tsx}"
app="$project/$glob"
types="../../../../node_modules/@types/**/*.d.ts"
# STEP 1 - format files in so prettier changes do not show up in diff because ts-migrate uses prettier
@hannahpun
hannahpun / tsconfig.json
Created June 16, 2021 23:26
tsconfig.json
{
"compilerOptions": {
"incremental": true,
"rootDir": ".",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"allowSyntheticDefaultImports": true,
"jsx": "react",
/* 一般型別 */
type A = "a" | "b" | "c";
type B = "b" | "c" | "d";
// Inferred Type: "b" | "c"
type Intersection = A & B;
/* 物件 */
type A = {
a: number;
type objProps = {
a: object; // Useful as a placeholder.
b: {}; // Can have any properties and values.
c: {
id: string;
title: string;
};
d: {
id: string;
title: string;
type BasicComponent = {
// Primitive data types 原始型別,可以是 boolean、number、string、null、undefined 以及 Symbol
a: number,
// Union Types,值可以為多種型別中的一種,以下可以是 number 或 string
b: number | string,
// Optional Properties 可有可無
c?: string,
// Literal Type 明文型別,值本身就是型別,也就是 d 一定要等於 'Hello'
d: 'Hello',
// 特殊型別,包括 any、never
// 這裡是用 type 引入但其實 RouteComponentProps 是 interface
import type { RouteComponentProps } from 'react-router';
interface globalProps {
history: RouteComponentProps['history'];
matchUrl: string;
};
interface someComponentProps extends globalProps {
data: {
type FunctionProps = {
// Does not take any arguments. Does not return anything.
onHover: () => void;
// Takes a number. Returns nothing (e.g. undefined).
onChange: (id: number) => void;
// Takes an event that is based on clicking on a button.
// Returns nothing.
onClick(event: React.MouseEvent<HTMLButtonElement>): void;
};