Skip to content

Commit

Permalink
update compiler (#1868)
Browse files Browse the repository at this point in the history
* update compiler

* remove preserve
  • Loading branch information
lolopinto authored Dec 29, 2024
1 parent 85a80c5 commit 26e7a6a
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions ts/src/tsc/compilerOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ export function readCompilerOptions(filePath: string) {
if (options.moduleResolution === "node") {
options.moduleResolution = ts.ModuleResolutionKind.NodeJs;
}
options.target = getTarget(options.target as string | undefined);
options.module = getModule(options.module as string | undefined);
return options;
}

Expand Down Expand Up @@ -65,6 +67,35 @@ export function getTarget(target?: string): ts.ScriptTarget {
}
}

export function getModule(module?: string): ts.ModuleKind {
switch (module?.toLowerCase()) {
case "none":
return ts.ModuleKind.None;
case "commonjs":
return ts.ModuleKind.CommonJS;
case "amd":
return ts.ModuleKind.AMD;
case "umd":
return ts.ModuleKind.UMD;
case "system":
return ts.ModuleKind.System;
case "es2015":
return ts.ModuleKind.ES2015;
case "es2020":
return ts.ModuleKind.ES2020;
case "es2022":
return ts.ModuleKind.ES2022;
case "esnext":
return ts.ModuleKind.ESNext;
case "node16":
return ts.ModuleKind.Node16;
case "nodenext":
return ts.ModuleKind.NodeNext;
default:
return ts.ModuleKind.CommonJS;
}
}

export function getTargetFromCurrentDir(): ts.ScriptTarget {
const options = readCompilerOptions(".");
return getTarget(options.target?.toString());
Expand Down

0 comments on commit 26e7a6a

Please sign in to comment.