Design Patterns · Middle · Question 26 of 75
Why does every slice in FSD have a public API (index.ts)?
- ✓Correct answer: So outside code depends only on the slice's explicit exports
- 2So the bundler can load a slice in one request instead of several
- 3So TypeScript can check the types inside the slice
Explanation
A public API is the module's contract (a Facade): the internal structure can change as long as the exports don't. A linter (Steiger, eslint plugins) forbids "deep" imports that bypass index.