Skip to content

Commit 4829c1f

Browse files
authored
Merge pull request #833 from ioBroker/copilot/fix-import-type-false-positives
Fix W5042 false positives for TypeScript `import type` statements
2 parents c71fc3f + 91df5fb commit 4829c1f

2 files changed

Lines changed: 6 additions & 1 deletion

File tree

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ Example:
2525
Placeholder for the next version (at the beginning of the line):
2626
### **WORK IN PROGRESS**
2727
-->
28+
### **WORK IN PROGRESS**
29+
- (@copilot) Fixed false positive W5042 for TypeScript type-only imports: `import type { Foo } from 'pkg'` no longer registers `pkg` as a required runtime dependency. Related to [#833]
30+
2831
### 5.10.2 (2026-04-11)
2932
- (@copilot) Fixed false positive `[E9507]` for i18n directories inside source directories (`src-rules`, `rules-src`, `src-editor`, `src-widgets`, `admin/src`, etc.) by expanding the ignored source directory list and checking the full parent path instead of only the top-level segment. Related to [#828].
3033
- (@copilot) Added adapter-specific exceptions to E0050 blacklist: `@iobroker/plugin-sentry` is now allowed as a dependency for `ioBroker.javascript`.

lib/M5000_Code.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,9 @@ function extractImports(content) {
226226
// import statements are each matched independently.
227227
// The negative lookahead (?!\s*\() excludes dynamic imports like import("pkg")
228228
// which would otherwise span many lines and falsely match 'from' in string literals.
229-
const fromPattern = /\b(?:import)\b(?!\s*\()[\s\S]*?\bfrom\s+['"`]([^'"`\n]+)['"`]/g;
229+
// The negative lookahead (?!\s+type\b) excludes TypeScript type-only imports like
230+
// `import type { Foo } from 'pkg'` which do not require runtime dependencies.
231+
const fromPattern = /\b(?:import)\b(?!\s*\()(?!\s+type\b)[\s\S]*?\bfrom\s+['"`]([^'"`\n]+)['"`]/g;
230232
while ((match = fromPattern.exec(code)) !== null) {
231233
common.debug(` import from: found ${match[1]}`);
232234
imports.add(match[1]);

0 commit comments

Comments
 (0)