Closed Lehoczky closed 1 year ago
I can confirm the problem occurs.
Having the same issue with Svelte.
I get this error when my tsconfig target is "esnext". When my target is "es2019" there is no error.
I get this error when my tsconfig target is "esnext". When my target is "es2019" there is no error.
this one helps!
It's the same for Vue 3 setup:
@storybook/vue3: 6.4.0-alpha.33 @vue/cli: 4.5.13 babel-loader: 8.2.2 vue-loader: 16.5.0
I assume these are Storybook's own deps that matter. Is there an explanation why this happens? I was under impression that in Storybook webpack config ts-loader is backed by babel-loader which is configured to transform optional chainings.
I get this error when my tsconfig target is "esnext". When my target is "es2019" there is no error.
Man, you saved my life :D. Thy!
Does anyone know about a workaround other than downgrading the es target? :pray:
This one is still happening sporadically on 6.5 beta
I found workaround on this page. https://stackoverflow.com/questions/60577517/storybook-config-in-typescript
It is working in my environment.
npm install --save-dev ts-node
.storybook/tsconfig.json
{
"extends": "..",
"compilerOptions": {
"target": "es2018",
"module": "esnext"
}
}
package.json
"scripts": {
...
"storybook": "TS_NODE_PROJECT=./.storybook/tsconfig.json start-storybook -p 6006",
...
}
npm run storybook
I tried out @hajimeni's proposed solution but it wasn't working. I've got the following error:
'TS_NODE_PROJECT' is not recognized as an internal or external command,
operable program or batch file.
To fix it I've had to install cross-env
too and then change package.json
too:
cross-env
:npm install cross-env --save-dev
package.json
"scripts": {
...
"storybook": "cross-env TS_NODE_PROJECT=./.storybook/tsconfig.json start-storybook -p 6006",
...
}
Another workaround. I have successfully activated storybook with the project presented in this issue. https://github.com/Lehoczky/storybook-bug-repro
@storybook/preset-typescript
npm install --save-dev @storybook/preset-typescript
const path = require('path');
module.exports = {
"stories": [
"../src/**/*.stories.mdx",
"../src/**/*.stories.@(js|jsx|ts|tsx)"
],
"addons": [
"@storybook/addon-links",
"@storybook/addon-essentials",
"@storybook/addon-interactions",
{
name: '@storybook/preset-typescript',
options: {
forkTsCheckerWebpackPluginOptions: {
tsconfig: path.resolve(__dirname, './tsconfig.json')
}
}
}
]
}
.storybook/tsconfig.json
{
"extends": "..",
"compilerOptions": {
"target": "es2018",
"module": "esnext"
}
}
npm run storybook
We’re cleaning house! Storybook has changed a lot since this issue was created and we don’t know if it’s still valid. Please open a new issue referencing this one if:
Describe the bug When using optional chaning inside a vue component, storybook gives the following error:
To Reproduce I created a small example at https://github.com/Lehoczky/storybook-bug-repro When I try to run storybook with
npm run storybook
i got the above error. Meanwhile the app runs fine withnpm run serve
.System