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

Props are not resolved as expected in props table with typescript #10804

Closed
kruthivijay31 opened this issue May 15, 2020 · 6 comments
Closed

Comments

@kruthivijay31
Copy link
Contributor

kruthivijay31 commented May 15, 2020

Describe the bug
Version: SB 5.3.18
index.tsx

type TooltipProps = {
   position?: 'left' | 'right' // Not getting resolved instead shows union
}

Current Output
Screen Shot 2020-05-15 at 4 35 34 PM

main.js

const path = require('path')

module.exports = {
  stories: ['../packages/**/*.story.mdx', '../packages/**/*.stories.tsx'],
  addons: [
    {
      name: '@storybook/preset-typescript',
      options: {
        tsLoaderOptions: {
          configFile: path.resolve(__dirname, '../tsconfig.json'),
        },
        transpileManager: true,
      },
    },
    {
      name: '@paypalcorp/storybook-preset',
      options: {
        parser: 'typescript'
      },
    },
    '@storybook/addon-viewport/register'
  ],
  webpackFinal: async config => {
    config.module.rules.push({
      test: /\.less$/,
      use: [
        'style-loader',
        'css-loader',
        {
          loader: 'less-loader', // compiles Less to CSS
          options: {
            paths: [path.resolve(__dirname, '../node_modules')],
          },
        },
      ],
    })
    config.resolve.extensions.push('.ts', '.tsx')
    return config
  },
}

Expected behavior

position: 'left' | 'right'

Similar to the image in this docs https://github.com/storybookjs/storybook/blob/next/addons/docs/react/README.md

TIA for helping me to figure this out!!

@shilman
Copy link
Member

shilman commented May 17, 2020

closing as dupe to #10311

@kruthivijay31
Copy link
Contributor Author

@shilman i am using 5.3 storybook and config is based on the doc https://storybook.js.org/docs/configurations/typescript-config/.

If you are not using CRA or have other requirements, then the next best option is @storybook/preset-typescript, which configures ts-loader under the hood.

Dupe mentioned is for 6.0. Please let me know what am i missing. I see in this example the values are resolved as expected https://github.com/storybookjs/storybook/blob/next/addons/docs/react/README.md

@shilman
Copy link
Member

shilman commented May 18, 2020

The behavior you’re seeing is a function of the CRA preset, not of SB 5.x vs 6.0

@kruthivijay31
Copy link
Contributor Author

kruthivijay31 commented May 18, 2020

Thanks, @shilman! I am not using CRA. Also how these values are resolved in the image example https://github.com/storybookjs/storybook/blob/next/addons/docs/react/README.md.

status: `positive` | `negative` | `neutral`

I am expecting the same behavior using the config mentioned in the docs. Not sure what am i missing?
Expected

position: 'left' | 'right'

Current output

position: 'union'

@shilman
Copy link
Member

shilman commented May 19, 2020

Are you suing a custom babel or webpack config?

@kruthivijay31
Copy link
Contributor Author

I am using webpack config with @storybook/preset-typescript. Details are added in the description.

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