Skip to content

Set esModuleInterop as default config of parse#511

Merged
pvasek merged 1 commit intostyleguidist:masterfrom
HUST-SE-LY:master
Jun 5, 2025
Merged

Set esModuleInterop as default config of parse#511
pvasek merged 1 commit intostyleguidist:masterfrom
HUST-SE-LY:master

Conversation

@HUST-SE-LY
Copy link
Copy Markdown

The React namespace is exported as CommonJs. As stated in TypeScript's Doc, we should always enable esModuleInterop.

Without esModuleInterop, example below will produce incorrect result because tsc cannot handle the default import(such as import React from 'react') of a CommonJs module correctly

import React from 'react';

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

/**
 * Jumbotron description
 */
export const Jumbotron: React.FC<JumbotronProps> = props => {
  return <div>Test</div>;
};

Currently, we always import React using the default import syntax. Additionally, when using tsc --init, esModuleInterop is enabled by default. For these reasons, I believe it is time to set esModuleInterop as the default configuration for the parse API.

@pvasek pvasek merged commit 490ff82 into styleguidist:master Jun 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants