Skip to content

Commit 06f8a8e

Browse files
committed
Improve types
1 parent d5eb876 commit 06f8a8e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

helpers/rollup/plugin.js

+16-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,14 @@
11
'use strict';
22

3-
function handleCircularDependancyWarning(warning, rollupWarn) {
3+
/**
4+
* @typedef {import('rollup')} rollup
5+
* @typedef {import('rollup').WarningHandlerWithDefault} rollup.WarningHandlerWithDefault
6+
*/
7+
8+
/**
9+
* @type {rollup.WarningHandlerWithDefault}
10+
*/
11+
function handleCircularDependancyWarning(warning, warningHandler) {
412
const packagesWithCircularDependencies = [
513
'util/',
614
'assert/',
@@ -10,12 +18,15 @@ function handleCircularDependancyWarning(warning, rollupWarn) {
1018
if (
1119
!(
1220
warning.code === 'CIRCULAR_DEPENDENCY' &&
13-
packagesWithCircularDependencies.some((modulePath) =>
14-
warning.importer.includes(modulePath)
15-
)
21+
packagesWithCircularDependencies.some((modulePath) => {
22+
if (typeof warning.importer !== 'string') {
23+
return false;
24+
}
25+
return warning.importer.includes(modulePath);
26+
})
1627
)
1728
) {
18-
rollupWarn(warning);
29+
warningHandler(warning);
1930
}
2031
}
2132

0 commit comments

Comments
 (0)