mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-31 08:07:10 -05:00
Remove dependence on module compiler option to consider mts/cts files always modules (#49815)
This commit is contained in:
@@ -6319,7 +6319,7 @@ namespace ts {
|
||||
// Excludes declaration files - they still require an explicit `export {}` or the like
|
||||
// for back compat purposes. The only non-declaration files _not_ forced to be a module are `.js` files
|
||||
// that aren't esm-mode (meaning not in a `type: module` scope).
|
||||
return (file.impliedNodeFormat === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts]))) && !file.isDeclarationFile ? true : undefined;
|
||||
return (file.impliedNodeFormat === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts, Extension.Mjs, Extension.Mts]))) && !file.isDeclarationFile ? true : undefined;
|
||||
}
|
||||
|
||||
export function getSetExternalModuleIndicator(options: CompilerOptions): (file: SourceFile) => void {
|
||||
@@ -6343,10 +6343,7 @@ namespace ts {
|
||||
if (options.jsx === JsxEmit.ReactJSX || options.jsx === JsxEmit.ReactJSXDev) {
|
||||
checks.push(isFileModuleFromUsingJSXTag);
|
||||
}
|
||||
const moduleKind = getEmitModuleKind(options);
|
||||
if (moduleKind === ModuleKind.Node16 || moduleKind === ModuleKind.NodeNext) {
|
||||
checks.push(isFileForcedToBeModuleByFormat);
|
||||
}
|
||||
checks.push(isFileForcedToBeModuleByFormat);
|
||||
const combined = or(...checks);
|
||||
const callback = (file: SourceFile) => void (file.externalModuleIndicator = combined(file));
|
||||
return callback;
|
||||
|
||||
Reference in New Issue
Block a user