TypeScript

TypeScript

GingerBook is written in TypeScript and provides first-class support for TypeScript.

tsconfig.json

GingerBook uses jsx-runtime so there is not need to import React at the top of each module. However, you need to let TypeScript know:

{
  "compilerOptions": {
    "jsx": "react-jsx"
  },
  "include": ["src", ".ginger-book"]
}

Exported Types

You can import many types from @ginger-society/ginger-book to improve your development experience:

import type { StoryDefault, Story } from "@ginger-society/ginger-book";

type Props = { label: string };

export default {
  title: "New title",
} satisfies StoryDefault<Props>;

const Card: Story<Props> = ({ label }) => <p>Label: {label}</p>;
Card.args = {
  label: "Hello",
};