From 6be1164d8917b1ee40d344151f387417352fc804 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Fri, 4 Jan 2019 08:39:07 +0530 Subject: [PATCH] Remove assertion for empty modules (#1450) --- js/compiler.ts | 1 - js/compiler_test.ts | 20 +++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/js/compiler.ts b/js/compiler.ts index ceb11f86109500..f8899135b500e5 100644 --- a/js/compiler.ts +++ b/js/compiler.ts @@ -244,7 +244,6 @@ export class Compiler } assert(moduleId != null, "No module ID."); assert(fileName != null, "No file name."); - assert(sourceCode ? sourceCode.length > 0 : false, "No source code."); assert( mediaType !== MediaType.Unknown, `Unknown media type for: "${moduleSpecifier}" from "${containingFile}".` diff --git a/js/compiler_test.ts b/js/compiler_test.ts index 21aab180ae3e97..3336b64b473c43 100644 --- a/js/compiler_test.ts +++ b/js/compiler_test.ts @@ -52,7 +52,7 @@ function mockModuleInfo( }; } -// Some fixtures we will us in testing +// Some fixtures we will use in testing const fooBarTsSource = `import * as deno from "deno"; console.log(deno); export const foo = "bar"; @@ -227,6 +227,14 @@ const moduleMap: { "console.log('foo');", undefined, undefined + ), + "empty_file.ts": mockModuleInfo( + "/moduleKinds/empty_file.ts", + "/moduleKinds/empty_file.ts", + MediaType.TypeScript, + "", + undefined, + undefined ) } }; @@ -637,3 +645,13 @@ test(function compilerResolveModuleNames() { } teardown(); }); + +test(function compilerResolveEmptyFile() { + setup(); + const result = compilerInstance.resolveModuleNames( + ["empty_file.ts"], + "/moduleKinds" + ); + assertEqual(result[0].resolvedFileName, "/moduleKinds/empty_file.ts"); + teardown(); +});