state updates (useState, useReducer)React.memo.React.memo skips re-render if props are shallow-equal.any and unknown in TypeScript?| Feature | any |
unknown |
|---|---|---|
| Type checking | Disabled (unsafe) | Required before use |
| Usage | No compiler checks | Forces narrowing via type guards |
| Example | let x: any; x.trim(); ✅ |
let x: unknown; x.trim(); ❌ (error) |
unknown when type is uncertain at runtime (e.g., catch (err: unknown)).typeof, instanceof).any = unsafe bypass, unknown = safer but requires explicit checks.