We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dccb6ee commit f1329f6Copy full SHA for f1329f6
packages/parser/src/parser.ts
@@ -36,19 +36,17 @@ function validateBoolean(
36
return value;
37
}
38
39
-const LIB_FILENAME_REGEX = /lib\.(.+)\.d\.ts/;
+const LIB_FILENAME_REGEX = /lib\.(.+)\.d\.ts$/;
40
function getLib(compilerOptions: CompilerOptions): Lib[] {
41
if (compilerOptions.lib) {
42
- return compilerOptions.lib
43
- .map(lib => {
44
- const match = LIB_FILENAME_REGEX.exec(lib.toLowerCase());
45
- if (!match) {
46
- return null;
47
- }
48
-
49
- return match[1] as Lib;
50
- })
51
- .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[]);
52
53
54
const target = compilerOptions.target ?? ScriptTarget.ES5;
0 commit comments