Skip to content

Commit 2d4e834

Browse files
committed
Rename function
1 parent d6bf0fe commit 2d4e834

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

src/compiler/checker.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,7 @@ import {
303303
getIdentifierGeneratedImportReference,
304304
getIdentifierTypeArguments,
305305
getImmediatelyInvokedFunctionExpression,
306+
getImpliedNodeFormatForEmit,
306307
getInitializerOfBinaryExpression,
307308
getInterfaceBaseTypeNodes,
308309
getInvokedExpression,
@@ -413,7 +414,6 @@ import {
413414
IdentifierTypePredicate,
414415
idText,
415416
IfStatement,
416-
impliedNodeFormatForEmit,
417417
ImportAttribute,
418418
ImportAttributes,
419419
ImportCall,
@@ -4101,7 +4101,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
41014101
function canHaveSyntheticDefault(file: SourceFile | undefined, moduleSymbol: Symbol, dontResolveAlias: boolean, usage: Expression) {
41024102
const usageMode = file && getEmitSyntaxForModuleSpecifierExpression(usage);
41034103
if (file && usageMode !== undefined) {
4104-
const targetMode = impliedNodeFormatForEmit(file, compilerOptions);
4104+
const targetMode = getImpliedNodeFormatForEmit(file, compilerOptions);
41054105
if (usageMode === ModuleKind.ESNext && targetMode === ModuleKind.CommonJS && ModuleKind.Node16 <= moduleKind && moduleKind <= ModuleKind.NodeNext) {
41064106
// In Node.js, CommonJS modules always have a synthetic default when imported into ESM
41074107
return true;
@@ -5334,7 +5334,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
53345334
}
53355335

53365336
const targetFile = moduleSymbol?.declarations?.find(isSourceFile);
5337-
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getEmitSyntaxForModuleSpecifierExpression(reference), impliedNodeFormatForEmit(targetFile, compilerOptions));
5337+
const isEsmCjsRef = targetFile && isESMFormatImportImportingCommonjsFormatFile(getEmitSyntaxForModuleSpecifierExpression(reference), getImpliedNodeFormatForEmit(targetFile, compilerOptions));
53385338
if (getESModuleInterop(compilerOptions) || isEsmCjsRef) {
53395339
let sigs = getSignaturesOfStructuredType(type, SignatureKind.Call);
53405340
if (!sigs || !sigs.length) {
@@ -46777,8 +46777,8 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4677746777
if (
4677846778
moduleKind >= ModuleKind.ES2015 &&
4677946779
moduleKind !== ModuleKind.Preserve &&
46780-
((node.flags & NodeFlags.Ambient && impliedNodeFormatForEmit(getSourceFileOfNode(node), compilerOptions) === ModuleKind.ESNext) ||
46781-
(!(node.flags & NodeFlags.Ambient) && impliedNodeFormatForEmit(getSourceFileOfNode(node), compilerOptions) !== ModuleKind.CommonJS))
46780+
((node.flags & NodeFlags.Ambient && getImpliedNodeFormatForEmit(getSourceFileOfNode(node), compilerOptions) === ModuleKind.ESNext) ||
46781+
(!(node.flags & NodeFlags.Ambient) && getImpliedNodeFormatForEmit(getSourceFileOfNode(node), compilerOptions) !== ModuleKind.CommonJS))
4678246782
) {
4678346783
// export assignment is not supported in es6 modules
4678446784
grammarErrorOnNode(node, Diagnostics.Export_assignment_cannot_be_used_when_targeting_ECMAScript_modules_Consider_using_export_default_or_another_module_format_instead);

src/compiler/factory/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ import {
5858
getESModuleInterop,
5959
getExternalModuleName,
6060
getExternalModuleNameFromPath,
61+
getImpliedNodeFormatForEmit,
6162
getJSDocType,
6263
getJSDocTypeTag,
6364
getModifiers,
@@ -72,7 +73,6 @@ import {
7273
HasIllegalTypeParameters,
7374
Identifier,
7475
idText,
75-
impliedNodeFormatForEmit,
7676
ImportCall,
7777
ImportDeclaration,
7878
ImportEqualsDeclaration,
@@ -714,7 +714,7 @@ export function createExternalHelpersImportDeclarationIfNeeded(nodeFactory: Node
714714
if (compilerOptions.importHelpers && isEffectiveExternalModule(sourceFile, compilerOptions)) {
715715
let namedBindings: NamedImportBindings | undefined;
716716
const moduleKind = getEmitModuleKind(compilerOptions);
717-
if ((moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) || impliedNodeFormatForEmit(sourceFile, compilerOptions) === ModuleKind.ESNext) {
717+
if ((moduleKind >= ModuleKind.ES2015 && moduleKind <= ModuleKind.ESNext) || getImpliedNodeFormatForEmit(sourceFile, compilerOptions) === ModuleKind.ESNext) {
718718
// use named imports
719719
const helpers = getEmitHelpers(sourceFile);
720720
if (helpers) {

src/compiler/utilities.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8575,7 +8575,7 @@ function isFileForcedToBeModuleByFormat(file: SourceFile, options: CompilerOptio
85758575
// that aren't esm-mode (meaning not in a `type: module` scope).
85768576
//
85778577
// TODO: extension check never considered compilerOptions; should impliedNodeFormat?
8578-
return (impliedNodeFormatForEmit(file, options) === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts, Extension.Mjs, Extension.Mts]))) && !file.isDeclarationFile ? true : undefined;
8578+
return (getImpliedNodeFormatForEmit(file, options) === ModuleKind.ESNext || (fileExtensionIsOneOf(file.fileName, [Extension.Cjs, Extension.Cts, Extension.Mjs, Extension.Mts]))) && !file.isDeclarationFile ? true : undefined;
85798579
}
85808580

85818581
/** @internal */
@@ -8626,11 +8626,11 @@ export function importSyntaxAffectsModuleResolution(options: CompilerOptions) {
86268626
* `program.getModeForUsageLocation` should be used instead.
86278627
*/
86288628
export function getDefaultResolutionModeForFile(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): ResolutionMode {
8629-
return importSyntaxAffectsModuleResolution(options) ? impliedNodeFormatForEmit(sourceFile, options) : undefined;
8629+
return importSyntaxAffectsModuleResolution(options) ? getImpliedNodeFormatForEmit(sourceFile, options) : undefined;
86308630
}
86318631

86328632
/** @internal */
8633-
export function impliedNodeFormatForEmit(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): ResolutionMode {
8633+
export function getImpliedNodeFormatForEmit(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): ResolutionMode {
86348634
const moduleKind = getEmitModuleKind(options);
86358635
if (ModuleKind.Node16 <= moduleKind && moduleKind <= ModuleKind.NodeNext) {
86368636
return sourceFile.impliedNodeFormat;
@@ -8663,7 +8663,7 @@ export function shouldTransformImportCall(sourceFile: Pick<SourceFile, "fileName
86638663

86648664
/** @internal */
86658665
export function getEmitModuleFormatOfFile(sourceFile: Pick<SourceFile, "fileName" | "impliedNodeFormat" | "packageJsonScope">, options: CompilerOptions): ModuleKind {
8666-
return impliedNodeFormatForEmit(sourceFile, options) ?? getEmitModuleKind(options);
8666+
return getImpliedNodeFormatForEmit(sourceFile, options) ?? getEmitModuleKind(options);
86678667
}
86688668

86698669
type CompilerOptionKeys = keyof { [K in keyof CompilerOptions as string extends K ? never : K]: any; };

src/compiler/watch.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
getDefaultLibFileName,
5757
getDirectoryPath,
5858
getEmitScriptTarget,
59+
getImpliedNodeFormatForEmit,
5960
getLineAndCharacterOfPosition,
6061
getNewLineCharacter,
6162
getNormalizedAbsolutePath,
@@ -66,7 +67,6 @@ import {
6667
getRelativePathFromDirectory,
6768
getWatchFactory,
6869
HasCurrentDirectory,
69-
impliedNodeFormatForEmit,
7070
isExternalOrCommonJsModule,
7171
isLineBreak,
7272
isReferencedFile,
@@ -379,7 +379,7 @@ export function explainIfFileIsRedirectAndImpliedFormat(
379379
));
380380
}
381381
if (isExternalOrCommonJsModule(file)) {
382-
switch (impliedNodeFormatForEmit(file, options)) {
382+
switch (getImpliedNodeFormatForEmit(file, options)) {
383383
case ModuleKind.ESNext:
384384
if (file.packageJsonScope) {
385385
(result ??= []).push(chainDiagnosticMessages(

src/services/codefixes/importFixes.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import {
4343
getEmitModuleResolutionKind,
4444
getEmitScriptTarget,
4545
getExportInfoMap,
46+
getImpliedNodeFormatForEmit,
4647
getMeaningFromDeclaration,
4748
getMeaningFromLocation,
4849
getNameForExportedSymbol,
@@ -58,7 +59,6 @@ import {
5859
getUniqueSymbolId,
5960
hostGetCanonicalFileName,
6061
Identifier,
61-
impliedNodeFormatForEmit,
6262
ImportClause,
6363
ImportEqualsDeclaration,
6464
importFromModuleSpecifier,
@@ -855,8 +855,8 @@ function shouldUseRequire(sourceFile: SourceFile, program: Program): boolean {
855855
// 4. In --module nodenext, assume we're not emitting JS -> JS, so use
856856
// whatever syntax Node expects based on the detected module kind
857857
// TODO: consider removing `impliedNodeFormatForEmit`
858-
if (impliedNodeFormatForEmit(sourceFile, compilerOptions) === ModuleKind.CommonJS) return true;
859-
if (impliedNodeFormatForEmit(sourceFile, compilerOptions) === ModuleKind.ESNext) return false;
858+
if (getImpliedNodeFormatForEmit(sourceFile, compilerOptions) === ModuleKind.CommonJS) return true;
859+
if (getImpliedNodeFormatForEmit(sourceFile, compilerOptions) === ModuleKind.ESNext) return false;
860860

861861
// 5. Match the first other JS file in the program that's unambiguously CJS or ESM
862862
for (const otherFile of program.getSourceFiles()) {
@@ -1166,7 +1166,7 @@ function getUmdImportKind(importingFile: SourceFile, compilerOptions: CompilerOp
11661166
return ImportKind.Namespace;
11671167
case ModuleKind.Node16:
11681168
case ModuleKind.NodeNext:
1169-
return impliedNodeFormatForEmit(importingFile, compilerOptions) === ModuleKind.ESNext ? ImportKind.Namespace : ImportKind.CommonJS;
1169+
return getImpliedNodeFormatForEmit(importingFile, compilerOptions) === ModuleKind.ESNext ? ImportKind.Namespace : ImportKind.CommonJS;
11701170
default:
11711171
return Debug.assertNever(moduleKind, `Unexpected moduleKind ${moduleKind}`);
11721172
}

src/services/suggestionDiagnostics.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ import {
2323
getAllowSyntheticDefaultImports,
2424
getAssignmentDeclarationKind,
2525
getFunctionFlags,
26+
getImpliedNodeFormatForEmit,
2627
hasInitializer,
2728
hasPropertyAccessExpressionWithName,
2829
Identifier,
29-
impliedNodeFormatForEmit,
3030
importFromModuleSpecifier,
3131
isAsyncFunction,
3232
isBinaryExpression,
@@ -67,7 +67,7 @@ export function computeSuggestionDiagnostics(sourceFile: SourceFile, program: Pr
6767
program.getSemanticDiagnostics(sourceFile, cancellationToken);
6868
const diags: DiagnosticWithLocation[] = [];
6969
const checker = program.getTypeChecker();
70-
const isCommonJSFile = impliedNodeFormatForEmit(sourceFile, program.getCompilerOptions()) === ModuleKind.CommonJS || fileExtensionIsOneOf(sourceFile.fileName, [Extension.Cts, Extension.Cjs]);
70+
const isCommonJSFile = getImpliedNodeFormatForEmit(sourceFile, program.getCompilerOptions()) === ModuleKind.CommonJS || fileExtensionIsOneOf(sourceFile.fileName, [Extension.Cts, Extension.Cjs]);
7171

7272
if (
7373
!isCommonJSFile &&

src/services/utilities.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ import {
9696
getEmitModuleKind,
9797
getEmitScriptTarget,
9898
getExternalModuleImportEqualsDeclarationExpression,
99+
getImpliedNodeFormatForEmit,
99100
getImpliedNodeFormatForFile,
100101
getIndentString,
101102
getJSDocEnumTag,
@@ -124,7 +125,6 @@ import {
124125
identity,
125126
idText,
126127
IfStatement,
127-
impliedNodeFormatForEmit,
128128
ImportClause,
129129
ImportDeclaration,
130130
ImportSpecifier,
@@ -4252,7 +4252,7 @@ export function fileShouldUseJavaScriptRequire(file: SourceFile | string, progra
42524252
fileName: file,
42534253
impliedNodeFormat: getImpliedNodeFormatForFile(toPath(file, host.getCurrentDirectory(), hostGetCanonicalFileName(host)), program.getPackageJsonInfoCache?.(), host, compilerOptions),
42544254
} : file;
4255-
const impliedNodeFormat = impliedNodeFormatForEmit(sourceFileLike, compilerOptions);
4255+
const impliedNodeFormat = getImpliedNodeFormatForEmit(sourceFileLike, compilerOptions);
42564256

42574257
if (impliedNodeFormat === ModuleKind.ESNext) {
42584258
return false;

0 commit comments

Comments
 (0)