@freck/ 详尽无遗的js
为检查穷尽性提供了帮助功能。 疲劳性检查是一种语言的特点,即类型检查器保证覆盖所有案件.
安装
pnpm add @freckle/exhaustive
这一一揽子措施仅限无害环境管理.
使用量
import {exhaustive} from '@freckle/exhaustive'
type Status = 'success' | 'failure'
function getStatusMessage(status: Status): string {
switch (status) {
case 'success':
return 'The operation completed successfully.'
case 'failure':
return 'The operation failed.'
default:
return exhaustive(status)
}
}
在默认情况下返回状态本身是常见模式的还原器中使用:
import {exhaustiveReducer} from '@freckle/exhaustive'
type TodoState = {...}
type TodoAction = {type: 'todoAdded', ...} | {type: 'todoToggled', ...}
const defaultTodoState = {...}
function todoReducer(
state: TodoState = defaultTodoState,
action: TodoAction
): TodoState {
switch (action.type) {
case 'todoAdded':
return {...}
case 'todoToggled':
return {...}
default:
return exhaustiveReducer(action.type, state)
}
}
发展
- 软件包管理器: pnpm(节点版本被钉入)
.nvmrc(中文(简体) ) pnpm build—— 说tsc通过tsconfig.build.json; 发送到dist/pnpm test- 维特pnpm coverage- 覆盖率为70%的Vitest(线路/行/功能/说明)pnpm typecheck—— 说tsc --noEmit,包括测试文件pnpm lint——ESLint公司pnpm format编号 :pnpm format-check- 更高级pnpm knip——未用文件/依赖/导出- CI在每份公关上 都查了一下
dist/最新数据
dist/ 承诺。 运行 pnpm build 在推进之前.
释放
见 发 言 更多细节.