Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Knobs panel is not displayed with addons.ts #3970

Closed
Nachasic opened this issue Aug 6, 2018 · 2 comments
Closed

Knobs panel is not displayed with addons.ts #3970

Nachasic opened this issue Aug 6, 2018 · 2 comments

Comments

@Nachasic
Copy link

Nachasic commented Aug 6, 2018

With @storybook/react (v3.4.10) + typescript 2.9 knobs addon panel is not displayed.

I am using custom webpack configuration in full-control mode, webpack.config.js:

module.exports = (baseConfig, env, config) => {
  config.module.rules.push({
    test: /\.(ts|tsx)$/,
    loader: 'awesome-typescript-loader',
    options: {
      configFileName: 'tsconfig.storybook.json'
    }
  });

  config.module.rules.push({
    test: /\.less$/,
    loader: 'less-loader'
  });
  
  config.resolve.extensions.push(".ts", ".tsx");
  return config;
};

tsconfig.storybook.json

{
    "compilerOptions": {
      "outDir": "build/lib",
      "module": "commonjs",
      "target": "es5",
      "lib": ["es5", "es6", "es7", "es2017", "dom"],
      "sourceMap": true,
      "allowJs": false,
      "jsx": "react",
      "moduleResolution": "node",
      "rootDirs": ["components"],
      "baseUrl": "src",
      "forceConsistentCasingInFileNames": true,
      "noImplicitReturns": true,
      "noImplicitThis": true,
      "noImplicitAny": true,
      "strictNullChecks": true,
      "suppressImplicitAnyIndexErrors": true,
      "noUnusedLocals": true,
      "declaration": true,
      "allowSyntheticDefaultImports": true,
      "experimentalDecorators": true
    },
    "include": ["components/**/*"],
    "exclude": ["node_modules", "build", "scripts"]
  }

config.js

import { configure } from '@storybook/react';

function loadStories () {
    require('../components/_stories_/mycomponent.stories.tsx');
};
configure(loadStories, module);

addons.ts

import '@storybook/addon-actions/register';
import '@storybook/addon-knobs/register';

mycomponent.stories.ts

import * as React from 'react';
import { storiesOf } from '@storybook/react';
import { withKnobs, text } from '@storybook/addon-knobs/react';
import { action } from '@storybook/addon-actions';

const stories = storiesOf('Input element', module);

stories.addDecorator(withKnobs)

stories
    .add(
        'Inline input',
        () => <input
                type="text"
                value={text('value', 'test')} 
                onChange={action('change')}/>
        )

From package.json

"devDependencies": {
    "@storybook/addon-actions": "^3.4.10",
    "@storybook/addon-info": "^3.4.10",
    "@storybook/addon-knobs": "^3.4.10",
    "@storybook/addons": "^3.4.10",
    "@storybook/react": "^3.4.10",
}

Expected result

Both actions and knobs panels are accessible and functional.

Actual result

Only actions panel is accessible and functional, no build or runtime errors.

Workaround

Rename addons.ts to addons.js, then it's fine.

@igor-dv
Copy link
Member

igor-dv commented Aug 6, 2018

.ts support for addons file is released only with the alpha version.

@stale
Copy link

stale bot commented Aug 27, 2018

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants