diff --git a/scripts/check-type-dependencies.js b/scripts/check-type-dependencies.js index 4374e36ae6..ba362bd5ff 100755 --- a/scripts/check-type-dependencies.js +++ b/scripts/check-type-dependencies.js @@ -74,11 +74,13 @@ function shouldCheckTypes(pkg) { } function findAllDeps(declSrc) { - const importedDeps = (declSrc.match(/from '.*'/g) || []) - .map(match => match.replace(/from '(.*)'/, '$1')) + const importedDeps = (declSrc.match(/^import .* from '.*';$/gm) || []) + .map(match => match.match(/from '(.*)'/)[1]) .filter(n => !n.startsWith('.')); - const referencedDeps = (declSrc.match(/types=".*"/g) || []) - .map(match => match.replace(/types="(.*)"/, '$1')) + const referencedDeps = ( + declSrc.match(/^\/\/\/ $/gm) || [] + ) + .map(match => match.match(/types="(.*)"/)[1]) .filter(n => !n.startsWith('.')) // We allow references to these without an explicit dependency. .filter(n => !['node', 'react'].includes(n));