storybook: import markdown.md for addons "Cannot find module"
Issue details
I want to use markdown.md with addons but I can’t import it
Steps to reproduce
I got error import README1 from ‘…/src/framework/content/README1.md’;
error TS2307: Cannot find module '../src/framework/content/README1.md'.
Please specify which version of Storybook and optionally any affected addons that you’re running
-storybook/addon-notes": “^3.3.11”, -storybook/angular": “^3.4.0-alpha.5”,
Screenshots / Screencast / Code Snippets (Optional)

About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 31 (10 by maintainers)
Try putting this in your TS code:
in CRA with typescript, can support markdown by editing react-app-dev.d.ts, add the declaration
and in your component
We were having trouble with this exact same issue because we had
"**/*.stories.*",in as an element inexcludein ourtsconfig.json. We had originally placed it there to preventstoriesfiles from being compiled into our bundles in our component library, but it was also causing this issue.Removing it and separately adding
*.stories*into our.npmignorefixed the issue while continuing to prevent the story files from getting bundled with our published package.Hope this helps someone having the same issue!
For me the errors go away if i switch the extension from ‘stories.tsx’ to just ‘tsx’
edit: actually any other extension that ‘stories.tsx’ works, even ‘story.tsx’
For those using Angular CLI with Storybook 3.4.0 release - you may have to add the typedef changes suggested by @amorenew in the typings.d.ts file in the src directory. That’s what got this to work for me!
Thanks for saving me a night of headaches tracking this down.
Hi guys, I’m still getting errors here. I’m making a simple documentation using Angular Material components. Here’s my brief Storybook configuration:
ng-cli
package.json
tsconfig.json
typings.d.ts
.storybook/addons.js
.storybook/config.js
src/app/material/mat-button.stories.ts
src/app/notes/mat-button-basic.md
Still getting error when compiling:
Am I missing something?
@cwmrowe check my tsconfig.json I have
and In typings.d.ts
Full repo https://github.com/amorenew/travel-angular/blob/master/.storybook/webpack.config.js but I still on alpha.5, not 8
create global.d.ts at the root level and add the single line of code below.
declare module ‘*.md’;
putting
declare module '*.md';in index.ts not workingI followed angular docs and then I made
typings.d.tsfile in root and I added in itand in tsconfig.json at compilerOptions I added
it works no error but I don’t think it returns value because
withNotesaddons doesn’t show text@vasinkevych
import * as readme from '../app/components/popup/README.md';worksnot
import README1 from '../src/framework/content/README1.md';Thanks a lot all.
Can you please create a GitHub repo with minimal reproduction of your issue?
@cwmrowe did you solve your question? i use
import * as docs from './button.md';but stillerror TS2307: Cannot find module './button.md'Thanks @amorenew
@amorenew, right
hi @amorenew, I’ve used your approach and added ‘marked’ module there is my story:
`import * as marked from ‘marked’; import * as readme from ‘…/app/components/popup/README.md’;
storiesOf(‘comp’, module) .addDecorator(withKnobs) .add( ‘withNotes’, withNotes({ text: marked(readme) })(() => ({ …story there })) ); `
👌 Will check tomorrow
@igor-dv mind taking a look?