Skip to content

Commit 490ff82

Browse files
authored
Merge pull request #511 from HUST-SE-LY/master
Set `esModuleInterop` as default config of `parse`
2 parents 66e6cd6 + 0740700 commit 490ff82

File tree

5 files changed

+26
-3
lines changed

5 files changed

+26
-3
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
3+
export interface JumbotronProps {
4+
/** prop1 description */
5+
prop1: string;
6+
}
7+
8+
/**
9+
* Jumbotron description
10+
*/
11+
export const Jumbotron: React.FC<JumbotronProps> = props => {
12+
return <div>Test</div>;
13+
};

src/__tests__/data/tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
/* Basic Options */
44
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
55
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
6+
"esModuleInterop": true,
67
// "lib": [], /* Specify library files to be included in the compilation: */
78
// "allowJs": true, /* Allow javascript files to be compiled. */
89
// "checkJs": true, /* Report errors in .js files. */

src/__tests__/parser.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,14 @@ describe('parser', () => {
781781
});
782782
});
783783

784+
it('should parse functional component declared as React.FC with default import from react', () => {
785+
check('FunctionalComponentWithDefaultImportReact', {
786+
Jumbotron: {
787+
prop1: { type: 'string', required: true }
788+
}
789+
});
790+
});
791+
784792
it('should parse functional component defined as const with default value assignments in immediately destructured props', () => {
785793
check('FunctionalComponentWithDesctructuredProps', {
786794
FunctionalComponentWithDesctructuredProps: {

src/parser.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,8 @@ export interface FileParser {
113113
export const defaultOptions: ts.CompilerOptions = {
114114
jsx: ts.JsxEmit.React,
115115
module: ts.ModuleKind.CommonJS,
116-
target: ts.ScriptTarget.Latest
116+
target: ts.ScriptTarget.Latest,
117+
esModuleInterop: true
117118
};
118119

119120
/**

0 commit comments

Comments
 (0)