TypeScript Path Alias Auto-Import with Multiple Root Directories
0 reputation · 13 Jan 2022, 23:52 UTC
WebStorm utilizes the TypeScript language service to provide auto-import suggestions based on the tsconfig.json configuration. In projects utilizing complex path aliases, it is possible to map a single alias to multiple root directories, such as "@/*": ["src/*", "packages/*"].
While the TypeScript compiler (tsc) correctly resolves modules across all defined roots, the IDE's auto-import mechanism appears to prioritize only the first entry in the array. This creates a discrepancy where symbols located in secondary root directories are not suggested for automatic import, despite being valid according to the compiler options.
Configuration Constraints
- Environment: WebStorm 2024.1 or later.
- Configuration:
compilerOptions.pathscontaining arrays with multiple directory mappings.
Is there a configuration setting to enable the resolution of all mapped roots for auto-imports, or a way to prioritize specific directories within a multi-root alias?