File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3794,12 +3794,17 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
37943794 // are ESM, there cannot be a synthetic default.
37953795 return false;
37963796 }
3797- // For declaration files from project references, check if the referenced project's
3798- // emit format is ESM, in which case there cannot be a synthetic default
3799- if (file.isDeclarationFile && host.getRedirectFromSourceFile(file.path)) {
3800- const targetModuleKind = host.getEmitModuleFormatOfFile(file);
3801- if (usageMode === ModuleKind.ESNext && targetModuleKind >= ModuleKind.ES2015) {
3802- return false;
3797+ // For other files (not node16/nodenext with impliedNodeFormat), check if we can determine
3798+ // the module format from project references
3799+ if (!targetMode && file.isDeclarationFile) {
3800+ const redirect = host.getRedirectFromSourceFile(file.path);
3801+ if (redirect) {
3802+ // This is a declaration file from a project reference, so we can determine
3803+ // its module format from the referenced project's options
3804+ const targetModuleKind = host.getEmitModuleFormatOfFile(file);
3805+ if (usageMode === ModuleKind.ESNext && targetModuleKind >= ModuleKind.ES2015) {
3806+ return false;
3807+ }
38033808 }
38043809 }
38053810 }
You can’t perform that action at this time.
0 commit comments