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

Commit 3d3cfad

Browse files
HeymdallKnisterPeter
authored andcommitted
fix(typings): handle one more type of es6 exports (#287)
1 parent 7a7153b commit 3d3cfad

File tree

4 files changed

+29
-0
lines changed

4 files changed

+29
-0
lines changed

Diff for: src/typings.ts

+2
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ function getComponentExportType(ast: AstQuery, componentName: string): dom.Decla
372372
// VariableDeclaration
373373
/ VariableDeclarator
374374
/:id Identifier[@name == '${componentName}']
375+
||
376+
/Identifier[@name == '${componentName}']
375377
]
376378
,
377379
// AssignmentExpression[

Diff for: tests/es7-class-separate-export.d.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
declare module 'component' {
2+
import * as React from 'react';
3+
export interface ComponentProps {
4+
optionalAny?: any;
5+
}
6+
export default class Component extends React.Component<ComponentProps, any>{
7+
}
8+
}

Diff for: tests/es7-class-separate-export.jsx

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import {Component, PropTypes} from 'react';
2+
3+
class Component extends Component {
4+
5+
static propTypes = {
6+
optionalAny: PropTypes.any,
7+
};
8+
9+
render() {
10+
return (
11+
<div />
12+
);
13+
}
14+
}
15+
16+
export default Component;

Diff for: tests/parsing-test.ts

+3
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ test('Parsing should create definition from babeled es7 class component', t => {
5555
};
5656
compare(t, 'component', 'es7-class-babeled.js', 'es7-class.d.ts', opts);
5757
});
58+
test('Parsing should create definition from es7 class component with separate default export', t => {
59+
compare(t, 'component', 'es7-class-separate-export.jsx', 'es7-class-separate-export.d.ts');
60+
});
5861
test('Parsing should create definition from stateless function component', t => {
5962
compare(t, 'component', 'stateless.jsx', 'stateless.d.ts');
6063
});

0 commit comments

Comments
 (0)