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

Extend interface with absolute import

Open romanlex opened this issue 3 years ago • 0 comments

When I'm trying to change the imports from relative paths to absolute paths I loose my extended types in styleguidist. I'm trying check this with direct call of react-docgen-typescript Example file

import { Display } from './mixins/display'
import { BaseProps } from './shared/interfaces'

export interface Props extends BaseProps, Display {
  print?: boolean
}

export function PrintValues(props: Props) {
  return null
}

Parse file

const docgen = require('react-docgen-typescript')

const options = {
  savePropValueAsString: true,
}

const customParser = docgen.withDefaultConfig(options)

const docs = customParser.parse('./src/test.tsx')

Output with relative paths of interface

[
  {
    tags: {},
    filePath: 'src/test.tsx',
    description: '',
    displayName: 'PrintValues',
    methods: [],
    props: {
      print: [Object],
      className: [Object],
      style: [Object],
      display: [Object]
    }
  }
]

Output with absolute paths(tsc work without any errors):

[
  {
    tags: {},
    filePath: 'src/test.tsx',
    description: '',
    displayName: 'PrintValues',
    methods: [],
    props: { print: [Object] }
  }
]

romanlex avatar May 28 '22 08:05 romanlex