Skip to content

Commit

Permalink
feat: set esModuleInterop as default config
Browse files Browse the repository at this point in the history
  • Loading branch information
liuyuan committed Dec 19, 2024
1 parent 6803c92 commit 0740700
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions src/__tests__/data/FunctionalComponentWithDefaultImportReact.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';

export interface JumbotronProps {
/** prop1 description */
prop1: string;
}

/**
* Jumbotron description
*/
export const Jumbotron: React.FC<JumbotronProps> = props => {
return <div>Test</div>;
};
1 change: 1 addition & 0 deletions src/__tests__/data/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
/* Basic Options */
"target": "es5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', or 'ESNEXT'. */
"module": "commonjs", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"esModuleInterop": true,
// "lib": [], /* Specify library files to be included in the compilation: */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
Expand Down
8 changes: 8 additions & 0 deletions src/__tests__/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -776,6 +776,14 @@ describe('parser', () => {
});
});

it('should parse functional component declared as React.FC with default import from react', () => {
check('FunctionalComponentWithDefaultImportReact', {
Jumbotron: {
prop1: { type: 'string', required: true }
}
});
});

it('should parse functional component defined as const with default value assignments in immediately destructured props', () => {
check('FunctionalComponentWithDesctructuredProps', {
FunctionalComponentWithDesctructuredProps: {
Expand Down
3 changes: 2 additions & 1 deletion src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export interface FileParser {
export const defaultOptions: ts.CompilerOptions = {
jsx: ts.JsxEmit.React,
module: ts.ModuleKind.CommonJS,
target: ts.ScriptTarget.Latest
target: ts.ScriptTarget.Latest,
esModuleInterop: true
};

/**
Expand Down

0 comments on commit 0740700

Please sign in to comment.