import { useState } from 'react' import { match } from 'ts-pattern' function Test() { const [currentTab, setCurrentTab] = useState<0 | 1 | 2>(0) return ( <Tabs> {match(currentTab) .with(0, () => <Tabs.Tab>Tab 0</Tabs.Tab>) .with(1, () => <Tabs.Tab>Tab 1</Tabs....
React.useReducer Demo Handling untyped API response Demo P.when Guard Demo P.not Pattern Demo P.select Pattern Demo P.union Pattern Demo Getting Started As an example, let's create a state reducer for a frontend application that fetches some data. Example: a state reducer with ts-pattern Our...
TypeScript在monorepo项目中实现即时更新 https://colinhacks.com/essays/live-types-typescript-monorepo monorepo docker 项目名:my-project docker-files/my-project 这个是为了针对单项目多服务的情况,所有 docker 都可以写到这里,不用单独放在子模块里面了 镜像最好已经安装了 pnpm# 基础镜像FROMnode:18.18.2pnpm8....
(x)": 这是一个glob模式匹配表达式,匹配所有的.ts和.tsx文件。.ts是TypeScript源文件,而.tsx是TypeScript编写的React JSX文件。 [ "prettier --no-error-on-unmatched-pattern --cache --parser=typescript --write" ]: 这是一个数组,其中包含了针对匹配到的.ts和.tsx文件所执行的命令字符串。 这个命令分...