draftbit / rescript-storybook

Storybook bindings for Rescript
80 stars 21 forks source link

Toplevel expression is expected to have unit type #21

Open painedpineapple opened 3 years ago

painedpineapple commented 3 years ago

I installed this via https://github.com/draftbit/bs-storybook to workaround #13. I am only attempting to write the basic story example when running into this error.

  3 │ let _module = %bs.raw("module")
  4 │ 
  5 │ storiesOf("My First Reason Story", _module)->add("Chapter I", () =>
  6 │   <span> {React.string("Hello bs-storybook!")} </span>
  7 │ )

  Toplevel expression is expected to have unit type.

FAILED: cannot make progress due to previous errors.
>>>> Finish compiling(exit: 1)

The word add on line 5 is what's highlighted in the error by the ReScript compiler

Using "bs-platform": "^8.4.2",

mishaszu commented 3 years ago

It seems like a fast pipe in the example doesn't work as expected and the add method returns while the module or function that contains the story shouldn't. I'm not that good with ReasonML to explain why. If you change to:

let my_section = storiesOf("My First Reason Story", _module);
let _ = add(my_section ,"Chapter I", () =><span> {React.string("Hello bs-storybook!")} </span>);

It should work