# 04 · discriminated-props **演示**:组件 props 用可辨识联合表达「error 必须带 message」;`useCounter` 展示 hook 的类型形态。 **运行**:在 `tutorials/typescript` 下执行 `npm run build`,再执行 `npm run serve`,打开 `http://localhost:8080/examples/29-jsx-react-types/04-discriminated-props/`;开 Console。 **预期控制台输出**: ```text
failed:1
ok
``` **类型检查**:`node node_modules/typescript/bin/tsc -p examples/29-jsx-react-types/04-discriminated-props/tsconfig.types.json` **注意**:`` 缺 `message` 会在 JSX 上直接报错;这是可辨识联合在组件层的价值。