Skip to content

Commit

Permalink
Remove assertion for empty modules (#1450)
Browse files Browse the repository at this point in the history
  • Loading branch information
Satya Rohith authored and ry committed Jan 4, 2019
1 parent 4f62a56 commit 6be1164
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
1 change: 0 additions & 1 deletion js/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}".`
Expand Down
20 changes: 19 additions & 1 deletion js/compiler_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
)
}
};
Expand Down Expand Up @@ -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();
});

0 comments on commit 6be1164

Please sign in to comment.