react-docgen-typescript-loader
react-docgen-typescript-loader copied to clipboard
import React from 'react' doesn't work
Changing the following:
-import * as React from 'react';
+import React from 'react';
Seems to break react-docgen-typescript-loader
's ability to generate docgen for components in the file.
Example of this is
interface IProps {
onChange: (event: React.ChangeEvent<HTMLInputElement>);
}
... this will render as (event: any) => void)
with import React from 'react'
, but renders properly with import * as React from 'react'
Normally Typescript disallows import React from 'react'
, however you can activate it in tsconfig.json
by setting the following:
{
"compilerOptions": {
"allowSyntheticDefaultImports": true,
}
}
I assume that this project simply haven't set that option and it therefor fails for every project who have set it too true.
edit It seems to be set for this project, so then I'm unsure what it is.
Specify path to your tsconfig.json
in tsconfigPath
.
{
loader: require.resolve('react-docgen-typescript-loader'),
options: {
tsconfigPath: path.resolve(__dirname, '../tsconfig.json')
}
},
@dizel3d - Thanks! That did the trick! I thought I'd specified that, but it turns out I'd only specified it for ts-loader
and forgot to add it to react-docgen-typescript-loader
.