@@ -934,6 +934,7 @@ import {
934
934
ShorthandPropertyAssignment,
935
935
shouldAllowImportingTsExtension,
936
936
shouldPreserveConstEnums,
937
+ shouldResolveJsRequire,
937
938
Signature,
938
939
SignatureDeclaration,
939
940
SignatureFlags,
@@ -3995,7 +3996,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
3995
3996
const hasDefaultOnly = isOnlyImportedAsDefault(specifier);
3996
3997
const hasSyntheticDefault = canHaveSyntheticDefault(file, moduleSymbol, dontResolveAlias, specifier);
3997
3998
if (!exportDefaultSymbol && !hasSyntheticDefault && !hasDefaultOnly) {
3998
- if (hasExportAssignmentSymbol(moduleSymbol) && !(getAllowSyntheticDefaultImports(compilerOptions) || getESModuleInterop(compilerOptions)) ) {
3999
+ if (hasExportAssignmentSymbol(moduleSymbol) && !allowSyntheticDefaultImports ) {
3999
4000
const compilerOptionName = moduleKind >= ModuleKind.ES2015 ? "allowSyntheticDefaultImports" : "esModuleInterop";
4000
4001
const exportEqualsSymbol = moduleSymbol.exports!.get(InternalSymbolName.ExportEquals);
4001
4002
const exportAssignment = exportEqualsSymbol!.valueDeclaration;
@@ -4138,7 +4139,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4138
4139
if (!isIdentifier(name)) {
4139
4140
return undefined;
4140
4141
}
4141
- const suppressInteropError = name.escapedText === InternalSymbolName.Default && !!(compilerOptions. allowSyntheticDefaultImports || getESModuleInterop(compilerOptions)) ;
4142
+ const suppressInteropError = name.escapedText === InternalSymbolName.Default && allowSyntheticDefaultImports;
4142
4143
const targetSymbol = resolveESModuleSymbol(moduleSymbol, moduleSpecifier, /*dontResolveAlias*/ false, suppressInteropError);
4143
4144
if (targetSymbol) {
4144
4145
if (name.escapedText) {
@@ -9177,7 +9178,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
9177
9178
// If `target` refers to a shorthand module symbol, the name we're trying to pull out isn;t recoverable from the target symbol
9178
9179
// In such a scenario, we must fall back to looking for an alias declaration on `symbol` and pulling the target name from that
9179
9180
let verbatimTargetName = isShorthandAmbientModuleSymbol(target) && getSomeTargetNameFromDeclarations(symbol.declarations) || unescapeLeadingUnderscores(target.escapedName);
9180
- if (verbatimTargetName === InternalSymbolName.ExportEquals && (getESModuleInterop(compilerOptions) || compilerOptions. allowSyntheticDefaultImports) ) {
9181
+ if (verbatimTargetName === InternalSymbolName.ExportEquals && allowSyntheticDefaultImports) {
9181
9182
// target refers to an `export=` symbol that was hoisted into a synthetic default - rename here to match
9182
9183
verbatimTargetName = InternalSymbolName.Default;
9183
9184
}
@@ -33993,7 +33994,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
33993
33994
}
33994
33995
33995
33996
// In JavaScript files, calls to any identifier 'require' are treated as external module imports
33996
- if (isInJSFile(node) && getEmitModuleResolutionKind (compilerOptions) !== ModuleResolutionKind.Bundler && isCommonJsRequire(node)) {
33997
+ if (isInJSFile(node) && shouldResolveJsRequire (compilerOptions) && isCommonJsRequire(node)) {
33997
33998
return resolveExternalModuleTypeByLiteral(node.arguments![0] as StringLiteral);
33998
33999
}
33999
34000
0 commit comments