React Styleguidist usage examples in typescript files

React Styleguidist uses external markdown files to store usage examples. We wanted to use typescript for examples because reasons and we managed to do this with horrible solution. It includes custom webpack loader that parses typescript file with regular expressions and converts it to markdown. You could find parts of our code below.

AlertBar.example.tsx contains usage example. styleguide.config.js contains parts of config replacing Styleguidist's webpack loader with examples-loader.js. examples.test.tsx is a usual Jest test covering all examples with snapshot tests.

Tags: , ,