[Storybook 6] The "zero-config" TypeScript config doesn't work on our project
See original GitHub issueDescribe the bug
A clear and concise description of what the bug is.
Build error for 2 syntaxes:
- const enum
declare
class fields
ERROR in ./src/plugins/FileService/constants.ts
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/jack/workspace/maskbook/src/plugins/FileService/constants.ts: 'const' enums are not supported.
9 | export const signing = 'https://service.maskbook.com/arweave-remote-signing'
10 |
> 11 | export const enum FileRouter {
| ^
12 | upload = '/upload',
13 | uploading = '/uploading',
14 | uploaded = '/uploaded',
ERROR in ./src/utils/ObservableMapSet.ts
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: /home/jack/workspace/maskbook/src/utils/ObservableMapSet.ts: TypeScript 'declare' fields must first be transformed by @babel/plugin-transform-typescript.
If you have already enabled that plugin (or '@babel/preset-typescript'), make sure that it runs before any plugin related to additional class features:
- @babel/plugin-proposal-class-properties
- @babel/plugin-proposal-private-methods
- @babel/plugin-proposal-decorators
2 | // Consider switch to libraries like Mobx if this file become too complex.
3 | export class ObservableWeakMap<K extends object, V> extends WeakMap<K, V> {
> 4 | declare __brand: 'Map'
| ^^^^^^^^^^^^^^^^^^^^^^
5 |
6 | event = new Emitter<{ delete: [K]; set: [K, V] }>()
7 | delete(key: K) {
To Reproduce
Reproduction: https://github.com/DimensionDev/Maskbook/pull/1568
Expected behavior Build successfully
System:
Please paste the results of npx sb@next info
here.
Environment Info:
System:
OS: Linux 5.8 Arch Linux
Binaries:
Node: 14.10.0 - /usr/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.7 - /usr/bin/npm
npmPackages:
@storybook/addon-actions: ^6.0.21 => 6.0.21
@storybook/addon-docs: ^6.0.21 => 6.0.21
@storybook/addon-info: ^5.3.21 => 5.3.21
@storybook/addon-knobs: ^6.0.21 => 6.0.21
@storybook/addon-links: ^6.0.21 => 6.0.21
@storybook/addon-viewport: ^6.0.21 => 6.0.21
@storybook/addons: ^6.0.21 => 6.0.21
@storybook/react: ^6.0.21 => 6.0.21
Additional context
Add any other context about the problem here.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:46
- Comments:25 (3 by maintainers)
Top Results From Across the Web
Zero-config Storybook
🧰 Built-in TypeScript Storybook 6.0's supports TypeScript using Babel transpilation with optional asynchronous type checking using fork-ts- ...
Read more >First-class Vite support in Storybook 7.0 : r/reactjs - Reddit
Zero config setup: Storybook extends from your existing Vite config file. ... My npm audit fix still doesn't work because of Storybook.
Read more >Storybook 6 zero-configuration. React Storybook setup tutorial.
Storybook is the world's favorite component workshop, widely adopted by industry giants, startups, and open -source projects alike.
Read more >Create your own design system! with Storybook React and ...
We're also going to use TSDX as our typescript tooling, it will help us get started quickly with zero configuration !
Read more >Newest 'tsdx' Questions - Stack Overflow
Its working with react app and story book when using it directly. in my case, ... My project's setup is tsdx (based on...
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
If you want this fixed, please upvote by adding a 👍 to the issue description. We use this to help prioritize!
Similar to other solutions, but this one worked for my project
in
main.js
Babel config is the part that is modified