flow
作者: facebook
針對React程式碼在DOM與原生平台上的靜態型別檢查。四種渲染器選項涵蓋標準DOM、瀏覽器特定程式碼、React Native及Fabric環境。執行yarn flow時可附加渲染器參數;使用yarn flow-ci進行全面但較慢的檢查。報告型別錯誤時會標示檔案位置,協助快速識別與修正問題。需留意常見陷阱:未指定渲染器、未審查的$FlowFixMe抑制標記,以及錯誤的型別匯入。
npx skills add https://github.com/facebook/react --skill flowFlow Type Checking
Arguments:
- $ARGUMENTS: Renderer to check (default: dom-node)
Renderers
| Renderer | When to Use |
|---|---|
dom-node | Default, recommended for most changes |
dom-browser | Browser-specific DOM code |
native | React Native |
fabric | React Native Fabric |
Instructions
- Run
yarn flow $ARGUMENTS(usedom-nodeif no argument) - Report type errors with file locations
- For comprehensive checking (slow), use
yarn flow-ci
Common Mistakes
- Running without a renderer - Always specify or use default
dom-node - Ignoring suppressions - Check if
$FlowFixMecomments are masking real issues - Missing type imports - Ensure types are imported from the correct package