Unexpected reserved word 'interface'
See original GitHub issueDescribe the bug
-
Initialize the project using
npx storybook@next init --type react -
Write components in typescript, define interfaces,An error occurred starting the project
-
Run a command
npm run storybook
Directory structure:
storybook-react-doc-v7.0
├── package-lock.json
├── package.json
├── src
│ └── Button.tsx
└── stories
├── Button.jsx
├── Button.stories.tsx
├── Header.jsx
├── Header.stories.js
├── Introduction.stories.mdx
├── Page.jsx
├── Page.stories.js
├── assets
│ ├── code-brackets.svg
│ ├── colors.svg
│ ├── comments.svg
│ ├── direction.svg
│ ├── flow.svg
│ ├── plugin.svg
│ ├── repo.svg
│ └── stackalt.svg
├── button.css
├── header.css
├── myIframe.stories.mdx
└── page.css
src/Button.tsx
Component Development Directory:
import React from "react";
interface IButtonProps {
/**
* 文字
*/
text: string;
}
export const Button = (props:IButtonProps) => {
return <div>{props.text}</div>;
};
stories/Button.stories.tsx
Reference components to write stories
import React from 'react';
import { Button } from '../src/Button';
export default {
/* 👇 The title prop is optional.
* See https://storybook.js.org/docs/7.0/react/configure/overview#configure-story-loading
* to learn how to generate automatic titles
*/
tags: ['docsPage'],
title: 'Button',
component: Button,
};
/*
*👇 Render functions are a framework specific feature to allow you control on how the component renders.
* See https://storybook.js.org/docs/7.0/react/api/csf
* to learn how to use render functions.
*/
export const Text = {
args:{
text:"xxxxx"
},
render: (props) => <Button text={props.text} ></Button>,
};
package.json
{
"name": "storybook-react-doc-v7.0",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"storybook": "storybook dev -p 6006",
"build-storybook": "storybook build"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@storybook/addon-essentials": "^7.0.0-alpha.54",
"@storybook/addon-interactions": "^7.0.0-alpha.54",
"@storybook/addon-links": "^7.0.0-alpha.54",
"@storybook/addons": "^6.5.13",
"@storybook/react": "^7.0.0-alpha.54",
"@storybook/react-webpack5": "^7.0.0-alpha.54",
"@storybook/testing-library": "^0.0.14-next.0",
"@storybook/theming": "^6.5.13",
"storybook": "^7.0.0-alpha.54"
},
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0"
}
}
Results of operation:

To Reproduce
No response
System
Environment Info:
System:
OS: macOS 12.5.1
CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
Yarn: 3.2.0 - ~/.nvm/versions/node/v18.12.1/bin/yarn
npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
Browsers:
Chrome: 107.0.5304.110
Safari: 15.6.1
npmPackages:
@storybook/addon-essentials: ^7.0.0-alpha.54 => 7.0.0-alpha.54
@storybook/addon-interactions: ^7.0.0-alpha.54 => 7.0.0-alpha.54
@storybook/addon-links: ^7.0.0-alpha.54 => 7.0.0-alpha.54
@storybook/addons: ^6.5.13 => 6.5.13
@storybook/react: ^7.0.0-alpha.54 => 7.0.0-alpha.54
@storybook/react-webpack5: ^7.0.0-alpha.54 => 7.0.0-alpha.54
@storybook/testing-library: ^0.0.14-next.0 => 0.0.14-next.0
@storybook/theming: ^6.5.13 => 6.5.13
Additional context
No response
Issue Analytics
- State:
- Created 10 months ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Jest test on typescript file syntax error: "interface is a reserved ...
In case just having the @babel/typescript preset does not work. You could try the following: Rename the failing test file to either .ts...
Read more >Unexpected reserved word 'interface' when running Jest with ...
I am new to Typescript and especially running Jest tests for a Typescript file. I am hoping this is wholly user-error. After setting...
Read more >Unexpected reserved word 'interface' error : r/typescript - Reddit
Unexpected reserved word 'interface' error. Hey all, I've been trying to learn unit testing with my reactjs and typescript project.
Read more >SyntaxError: Unexpected reserved word - Techy Things
SyntaxError: Unexpected reserved word. > 5 | import { Config } from 'src/js/config'; | ^. Where src/js/config is a config.ts Typescript file ...
Read more >@babel/plugin-transform-reserved-words - Package Manager
Fast, reliable, and secure dependency management.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@jonesmac No unfortunately I don’t think that it will show there. That only shows how we configure webpack, but I believe the Babel config loading happens “magically” by Babel. There are ways to debug this and I believe we’ve added them to the docs. However I’ll update the migration guide to be more explicit about all this. Thanks for debugging and helping make the upgrade smoother!
It does install the packages, if it can. @shilman