Skip to content

Commit fd7f4d3

Browse files
authored
Adding support for default exports (#58)
* Default export does not work - fixed
1 parent cf90374 commit fd7f4d3

15 files changed

+154
-26
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-docgen-typescript",
3-
"version": "1.1.0",
3+
"version": "1.2.0",
44
"description": "",
55
"main": "lib/index.js",
66
"scripts": {
@@ -11,7 +11,6 @@
1111
"print": "npm run tsc && node ./lib/print.js",
1212
"print:sample1": "npm run tsc && node ./lib/print.js ./src/__tests__/data/ColumnHigherOrderComponent.tsx simple"
1313
},
14-
"author": "pvasek",
1514
"license": "MIT",
1615
"dependencies": {},
1716
"devDependencies": {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as React from 'react';
2+
3+
/**
4+
* Column properties.
5+
*/
6+
export interface IColumnProps {
7+
/** prop1 description */
8+
prop1?: string;
9+
/** prop2 description */
10+
prop2: number;
11+
/**
12+
* prop3 description
13+
*/
14+
prop3: () => void;
15+
/** prop4 description */
16+
prop4: 'option1' | 'option2' | "option3";
17+
}
18+
19+
/**
20+
* ColumnWithDefaultAnonymousExportOnly description
21+
*/
22+
export default class extends React.Component<IColumnProps, {}> {
23+
public static defaultProps: Partial<IColumnProps> = {
24+
prop1: 'prop1'
25+
};
26+
27+
render() {
28+
const {prop1} = this.props;
29+
return <div>{prop1}</div>;
30+
}
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import * as React from 'react';
2+
3+
/**
4+
* Column properties.
5+
*/
6+
export interface IColumnProps {
7+
/** prop1 description */
8+
prop1?: string;
9+
/** prop2 description */
10+
prop2: number;
11+
/**
12+
* prop3 description
13+
*/
14+
prop3: () => void;
15+
/** prop4 description */
16+
prop4: 'option1' | 'option2' | "option3";
17+
}
18+
19+
/**
20+
* Column description
21+
*/
22+
class Column extends React.Component<IColumnProps, {}> {
23+
public static defaultProps: Partial<IColumnProps> = {
24+
prop1: 'prop1'
25+
};
26+
27+
render() {
28+
const {prop1} = this.props;
29+
return <div>{prop1}</div>;
30+
}
31+
}
32+
33+
export default Column;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import * as React from 'react';
2+
3+
/**
4+
* Column properties.
5+
*/
6+
export interface IColumnProps {
7+
/** prop1 description */
8+
prop1?: string;
9+
/** prop2 description */
10+
prop2: number;
11+
/**
12+
* prop3 description
13+
*/
14+
prop3: () => void;
15+
/** prop4 description */
16+
prop4: 'option1' | 'option2' | "option3";
17+
}
18+
19+
/**
20+
* ColumnWithDefaultExportOnly description
21+
*/
22+
export default class Column extends React.Component<IColumnProps, {}> {
23+
public static defaultProps: Partial<IColumnProps> = {
24+
prop1: 'prop1'
25+
};
26+
27+
render() {
28+
const {prop1} = this.props;
29+
return <div>{prop1}</div>;
30+
}
31+
}

src/__tests__/data/ColumnWithHtmlAttributes.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,4 @@ export class Column extends React.Component<IColumnProps, {}> {
2222
const {prop1} = this.props;
2323
return <div>{prop1}</div>;
2424
}
25-
}
26-
27-
export default Column;
25+
}

src/__tests__/data/ColumnWithPick.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,4 @@ export class Column extends React.Component<ColumnProps, {}> {
2929
const {prop1} = this.props;
3030
return <div>{prop1}</div>;
3131
}
32-
}
33-
34-
export default Column;
32+
}

src/__tests__/data/ColumnWithoutExportedProps.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,4 @@ export class Column extends React.Component<IColumnProps, {}> {
2121
const {prop1} = this.props;
2222
return <div>{prop1}</div>;
2323
}
24-
}
25-
26-
export default Column;
24+
}

src/__tests__/data/ConstExport.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,4 @@ export const Row = (props: IRowProps) => {
3636

3737
const nonExportedFunc = (props: IRowProps) => {
3838
return <div>No Export</div>
39-
};
40-
41-
export default Row;
39+
};

src/__tests__/data/FlippableImage.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,4 @@ export const FlippableImage = (props: Props) => {
3333
{...rest}
3434
/>
3535
);
36-
};
37-
38-
export default FlippableImage;
36+
};

src/__tests__/data/PureRow.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ export class Row extends React.PureComponent<IRowProps, {}> {
1919
return <div>Test</div>;
2020
}
2121
};
22-
23-
export default Row;

0 commit comments

Comments
 (0)