Skip to content
Permalink
Browse files

fix(parser): minor fix regexp, map-filter to reduce (#2684)

  • Loading branch information
Connormiha committed Oct 18, 2020
1 parent dccb6ee commit f1329f6c4e3d1de21b1dc59c30ce16503c346eee
Showing with 9 additions and 11 deletions.
  1. +9 −11 packages/parser/src/parser.ts
@@ -36,19 +36,17 @@ function validateBoolean(
return value;
}

const LIB_FILENAME_REGEX = /lib\.(.+)\.d\.ts/;
const LIB_FILENAME_REGEX = /lib\.(.+)\.d\.ts$/;
function getLib(compilerOptions: CompilerOptions): Lib[] {
if (compilerOptions.lib) {
return compilerOptions.lib
.map(lib => {
const match = LIB_FILENAME_REGEX.exec(lib.toLowerCase());
if (!match) {
return null;
}

return match[1] as Lib;
})
.filter(l => l != null) as Lib[];
return compilerOptions.lib.reduce((acc, lib) => {
const match = LIB_FILENAME_REGEX.exec(lib.toLowerCase());
if (match) {
acc.push(match[1] as Lib);
}

return acc;
}, [] as Lib[]);
}

const target = compilerOptions.target ?? ScriptTarget.ES5;

0 comments on commit f1329f6

Please sign in to comment.
You can’t perform that action at this time.