Skip to content
This repository was archived by the owner on Nov 20, 2020. It is now read-only.

Not working with compiled TypeScript declarations? #18

Closed
teddybradford opened this issue Jul 16, 2018 · 3 comments
Closed

Not working with compiled TypeScript declarations? #18

teddybradford opened this issue Jul 16, 2018 · 3 comments

Comments

@teddybradford
Copy link

teddybradford commented Jul 16, 2018

I'm trying to use this loader with a Node package that contains both .js files compiled from TypeScript and .d.ts declaration file counterparts. However, it appears that this loader might not be reading the declaration files to generate a proper docgen, and therefore isn't getting component names or proptypes. In Storybook, I'm seeing the following:

image

Does this loader support compiled TypeScript with declarations? If not, is there any workaround for this?

@teddybradford
Copy link
Author

Possibly related to #25

@teddybradford
Copy link
Author

Closing this, as I believe the solution documented in the following thread solves this same issue: #25 (comment)

@usagi-f
Copy link

usagi-f commented Jan 31, 2019

I have this problem.

For module made by me, did not work by below code.

// .storybook/webpack.config.js
const compilerOptions = {
  ...require('../../../tsconfig.json').compilerOptions,
};

delete compilerOptions.moduleResolution;

module.exports = (baseConfig, env, config) => {
  config.module.rules.push({
    test: /\.(ts|tsx)$/,
    use: [
      {
        loader: require.resolve('babel-loader'),
        options: {
          presets: [['react-app', { flow: false, typescript: true }]],
        },
      },
      {
        loader: require.resolve('react-docgen-typescript-loader'),
        options: { compilerOptions },
      },
    ],
  });
  config.resolve.extensions.push('.ts', '.tsx');
  return config;
};
// *.stories.tsx
import React from 'react';
import { storiesOf } from '@storybook/react';
import { Component } from 'original-modules';
storiesOf('Component', module).add('any caption', () => <Component />)

The exported component by modules has props information what only specific value for example defaultProps.
Because already build to not TypeScript.

For the reason, I am hoping to refer by *.d.ts but it rendered only defaultProps.

@teddybradford Did you resolve this issue? How about the implement way?

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

No branches or pull requests

2 participants