summaryrefslogtreecommitdiff
path: root/cli/js/compiler.ts
diff options
context:
space:
mode:
Diffstat (limited to 'cli/js/compiler.ts')
-rw-r--r--cli/js/compiler.ts23
1 files changed, 22 insertions, 1 deletions
diff --git a/cli/js/compiler.ts b/cli/js/compiler.ts
index 06117413a..abe145da2 100644
--- a/cli/js/compiler.ts
+++ b/cli/js/compiler.ts
@@ -1049,6 +1049,7 @@ interface SourceFileMapEntry {
interface CompilerRequestCompile {
type: CompilerRequestType.Compile;
+ allowJs: boolean;
target: CompilerHostTarget;
rootNames: string[];
configPath?: string;
@@ -1099,6 +1100,7 @@ interface RuntimeBundleResult {
function compile(request: CompilerRequestCompile): CompileResult {
const {
+ allowJs,
bundle,
config,
configPath,
@@ -1138,6 +1140,10 @@ function compile(request: CompilerRequestCompile): CompileResult {
}));
let diagnostics: readonly ts.Diagnostic[] = [];
+ if (!bundle) {
+ host.mergeOptions({ allowJs });
+ }
+
// if there is a configuration supplied, we need to parse that
if (config && config.length && configPath) {
const configResult = host.configure(cwd, configPath, config);
@@ -1167,7 +1173,22 @@ function compile(request: CompilerRequestCompile): CompileResult {
setRootExports(program, rootNames[0]);
}
const emitResult = program.emit();
- assert(emitResult.emitSkipped === false, "Unexpected skip of the emit.");
+ // If `checkJs` is off we still might be compiling entry point JavaScript file
+ // (if it has `.ts` imports), but it won't be emitted. In that case we skip
+ // assertion.
+ if (!bundle) {
+ if (options.checkJs) {
+ assert(
+ emitResult.emitSkipped === false,
+ "Unexpected skip of the emit."
+ );
+ }
+ } else {
+ assert(
+ emitResult.emitSkipped === false,
+ "Unexpected skip of the emit."
+ );
+ }
// emitResult.diagnostics is `readonly` in TS3.5+ and can't be assigned
// without casting.
diagnostics = emitResult.diagnostics;