isolatedModules does not imply every file is a module (#54218)

This commit is contained in:
Andrew Branch
2023-05-12 15:14:49 -07:00
committed by GitHub
parent 08285abaec
commit f0ff97611f
16 changed files with 50 additions and 40 deletions
+1 -1
View File
@@ -1857,7 +1857,7 @@ function isCommonJSContainingModuleKind(kind: ModuleKind) {
/** @internal */
export function isEffectiveExternalModule(node: SourceFile, compilerOptions: CompilerOptions) {
return isExternalModule(node) || getIsolatedModules(compilerOptions) || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
return isExternalModule(node) || (isCommonJSContainingModuleKind(getEmitModuleKind(compilerOptions)) && !!node.commonJsModuleIndicator);
}
/**
@@ -130,7 +130,7 @@ var x = 0;`, {
testVerbatimModuleSyntax: true
});
transpilesCorrectly("Generates module output", `var x = 0;`, {
transpilesCorrectly("Generates module output", `var x = 0; export {};`, {
options: { compilerOptions: { module: ts.ModuleKind.AMD } }
});
@@ -139,7 +139,7 @@ var x = 0;`, {
testVerbatimModuleSyntax: true
});
transpilesCorrectly("Sets module name", "var x = 1;", {
transpilesCorrectly("Sets module name", "var x = 1; export {};", {
options: { compilerOptions: { module: ts.ModuleKind.System, newLine: ts.NewLineKind.LineFeed }, moduleName: "NamedModule" }
});
+1
View File
@@ -304,6 +304,7 @@ describe("unittests:: TransformAPI", () => {
target: ts.ScriptTarget.ES5,
module: ts.ModuleKind.System,
newLine: ts.NewLineKind.CarriageReturnLineFeed,
moduleDetection: ts.ModuleDetectionKind.Force,
}
}).outputText;