Automatic Import behavior in mixed CommonJS and ESM environments
23K reputation · 01 Jan 2021, 16:54 UTC
WebStorm provides automatic import suggestions based on the project's module system. In large-scale TypeScript projects utilizing a mix of CommonJS and ECMAScript Modules (ESM), the IDE must resolve symbols across different module boundaries to provide accurate completion.
There is uncertainty regarding how the IDE prioritizes import styles when a symbol is available in both formats or when the tsconfig.json specifies a module system that conflicts with the local file's extension. This can lead to inconsistent suggestions where the IDE alternates between require() and import statements for the same dependency.
- Does WebStorm prioritize the project-level module setting or the individual file's module type when generating automatic imports?
- Is there a configuration to enforce a specific import style across mixed-module environments?