react-docgen-typescript-loader icon indicating copy to clipboard operation
react-docgen-typescript-loader copied to clipboard

Imported `enum` types are displayed with propType "any"

Open justinanastos opened this issue 6 years ago • 9 comments

If a component uses a prop of an enum that is imported from another file, the propType will be shown as any.

This will correctly label the color property as propType Color:

// SomeComponent.tsx
import * as React from 'react';

export enum Color {
  PRIMARY = 'primary',
  SECONDARY = 'secondary',
  COMPLEMENTARY = 'complementary',
  TERTIARY = 'tertiary',
  ANCILLARY = 'ancillary',
}

interface Props {
  /** The color */
  color?: Color;
}

const SomeComponent: React.SFC<Props> = (props) => {
  return 'test';
};

export default SomeComponent;

This will incorrectly label the color property as propType any:

// Color.ts
export enum Color {
  PRIMARY = 'primary',
  SECONDARY = 'secondary',
  COMPLEMENTARY = 'complementary',
  TERTIARY = 'tertiary',
  ANCILLARY = 'ancillary',
}
// SomeComponent.tsx
import * as React from 'react';
import { Color } from './Color';

interface Props {
  /** The color */
  color?: Color;
}

const SomeComponent: React.SFC<Props> = (props) => {
  return 'test';
};

export default SomeComponent;

justinanastos avatar Jun 09 '18 16:06 justinanastos