Skip to content

Commit

Permalink
chore(type-utils) refactored scoped package matching to do only one p…
Browse files Browse the repository at this point in the history
…ass over the package name
  • Loading branch information
marekdedic committed Apr 17, 2023
1 parent d0b5e15 commit e97628f
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/type-utils/src/TypeOrValueSpecifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,11 @@ function typeDeclaredInPackage(
// Handle scoped packages - if the name starts with @, remove it and replace / with __
const typesPackageName =
'@types/' + packageName.replace(/^@([^/]+)\//, '$1__');
return declarationFiles.some(
declaration =>
declaration.fileName.includes(`node_modules/${packageName}/`) ||
declaration.fileName.includes(`node_modules/${typesPackageName}/`),
const matcher = new RegExp(
`node_modules/(?:${packageName}|${typesPackageName})/`,
);
return declarationFiles.some(declaration =>
matcher.test(declaration.fileName),
);
}

Expand Down

0 comments on commit e97628f

Please sign in to comment.