diff --git a/internal/ast/utilities.go b/internal/ast/utilities.go index 73aa3a25c4..2ceb356f60 100644 --- a/internal/ast/utilities.go +++ b/internal/ast/utilities.go @@ -2384,7 +2384,7 @@ func GetImpliedNodeFormatForEmitWorker(fileName string, options *core.CompilerOp return sourceFileMetaData.ImpliedNodeFormat } if sourceFileMetaData != nil && sourceFileMetaData.ImpliedNodeFormat == core.ModuleKindCommonJS && - (sourceFileMetaData.PackageJsonType != "module" || + (sourceFileMetaData.PackageJsonType == "commonjs" || tspath.FileExtensionIsOneOf(fileName, []string{tspath.ExtensionCjs, tspath.ExtensionCts})) { return core.ModuleKindCommonJS } diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 3d771a4832..b5fea7253d 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -13576,7 +13576,27 @@ func (c *Checker) getTargetOfModuleDefault(moduleSymbol *ast.Symbol, node *ast.N } func (c *Checker) reportNonDefaultExport(moduleSymbol *ast.Symbol, node *ast.Node) { - // !!! + if moduleSymbol.Exports != nil && moduleSymbol.Exports[node.Symbol().Name] != nil { + c.error(node, diagnostics.Module_0_has_no_default_export_Did_you_mean_to_use_import_1_from_0_instead, c.symbolToString(moduleSymbol), c.symbolToString(node.Symbol())) + } else { + diagnostic := c.error(node.Name(), diagnostics.Module_0_has_no_default_export, c.symbolToString(moduleSymbol)) + var exportStar *ast.Symbol + if moduleSymbol.Exports != nil { + exportStar = moduleSymbol.Exports[ast.InternalSymbolNameExportStar] + } + if exportStar != nil { + defaultExport := core.Find(exportStar.Declarations, func(decl *ast.Declaration) bool { + if !(ast.IsExportDeclaration(decl) && decl.AsExportDeclaration().ModuleSpecifier != nil) { + return false + } + resolvedExternalModuleName := c.resolveExternalModuleName(decl, decl.AsExportDeclaration().ModuleSpecifier, false /*ignoreErrors*/) + return resolvedExternalModuleName != nil && resolvedExternalModuleName.Exports[ast.InternalSymbolNameDefault] != nil + }) + if defaultExport != nil { + diagnostic.AddRelatedInfo(createDiagnosticForNode(defaultExport, diagnostics.X_export_Asterisk_does_not_re_export_a_default)) + } + } + } } func (c *Checker) resolveExportByName(moduleSymbol *ast.Symbol, name string, sourceNode *ast.Node, dontResolveAlias bool) *ast.Symbol { @@ -13773,31 +13793,29 @@ func (c *Checker) isOnlyImportableAsDefault(usage *ast.Node, resolvedModule *ast } func (c *Checker) canHaveSyntheticDefault(file *ast.Node, moduleSymbol *ast.Symbol, dontResolveAlias bool, usage *ast.Node) bool { - // !!! - // var usageMode ResolutionMode - // if file != nil { - // usageMode = c.getEmitSyntaxForModuleSpecifierExpression(usage) - // } - // if file != nil && usageMode != core.ModuleKindNone { - // targetMode := host.getImpliedNodeFormatForEmit(file) - // if usageMode == core.ModuleKindESNext && targetMode == core.ModuleKindCommonJS && core.ModuleKindNode16 <= c.moduleKind && c.moduleKind <= core.ModuleKindNodeNext { - // // In Node.js, CommonJS modules always have a synthetic default when imported into ESM - // return true - // } - // if usageMode == core.ModuleKindESNext && targetMode == core.ModuleKindESNext { - // // No matter what the `module` setting is, if we're confident that both files - // // are ESM, there cannot be a synthetic default. - // return false - // } - // } + var usageMode core.ResolutionMode + if file != nil { + usageMode = c.getEmitSyntaxForModuleSpecifierExpression(usage) + } + if file != nil && usageMode != core.ModuleKindNone { + targetMode := c.program.GetImpliedNodeFormatForEmit(file.AsSourceFile()) + if usageMode == core.ModuleKindESNext && targetMode == core.ModuleKindCommonJS && core.ModuleKindNode16 <= c.moduleKind && c.moduleKind <= core.ModuleKindNodeNext { + // In Node.js, CommonJS modules always have a synthetic default when imported into ESM + return true + } + if usageMode == core.ModuleKindESNext && targetMode == core.ModuleKindESNext { + // No matter what the `module` setting is, if we're confident that both files + // are ESM, there cannot be a synthetic default. + return false + } + } if !c.allowSyntheticDefaultImports { return false } // Declaration files (and ambient modules) if file == nil || file.AsSourceFile().IsDeclarationFile { // Definitely cannot have a synthetic default if they have a syntactic default member specified - defaultExportSymbol := c.resolveExportByName(moduleSymbol, ast.InternalSymbolNameDefault /*sourceNode*/, nil /*dontResolveAlias*/, true) - // Dont resolve alias because we want the immediately exported symbol's declaration + defaultExportSymbol := c.resolveExportByName(moduleSymbol, ast.InternalSymbolNameDefault /*sourceNode*/, nil /*dontResolveAlias*/, true) // Dont resolve alias because we want the immediately exported symbol's declaration if defaultExportSymbol != nil && core.Some(defaultExportSymbol.Declarations, isSyntacticDefault) { return false } @@ -13814,7 +13832,12 @@ func (c *Checker) canHaveSyntheticDefault(file *ast.Node, moduleSymbol *ast.Symb return true } // TypeScript files never have a synthetic default (as they are always emitted with an __esModule marker) _unless_ they contain an export= statement - return hasExportAssignmentSymbol(moduleSymbol) + if !ast.IsInJSFile(file) { + return hasExportAssignmentSymbol(moduleSymbol) + } + + // JS files have a synthetic default if they do not contain ES2015+ module syntax (export = is not valid in js) _and_ do not have an __esModule marker + return !ast.IsExternalModule(file.AsSourceFile()) && c.resolveExportByName(moduleSymbol, "__esModule", nil /*sourceNode*/, dontResolveAlias) == nil } func (c *Checker) getEmitSyntaxForModuleSpecifierExpression(usage *ast.Node) core.ResolutionMode { diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports3.errors.txt b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports3.errors.txt new file mode 100644 index 0000000000..127332623a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports3.errors.txt @@ -0,0 +1,14 @@ +a.ts(1,8): error TS1192: Module '"b"' has no default export. + + +==== a.ts (1 errors) ==== + import Namespace from "./b"; + ~~~~~~~~~ +!!! error TS1192: Module '"b"' has no default export. + export var x = new Namespace.Foo(); + +==== b.ts (0 errors) ==== + export class Foo { + member: string; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports3.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports3.errors.txt.diff deleted file mode 100644 index 6142a6c835..0000000000 --- a/testdata/baselines/reference/submodule/compiler/allowSyntheticDefaultImports3.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.allowSyntheticDefaultImports3.errors.txt -+++ new.allowSyntheticDefaultImports3.errors.txt -@@= skipped -0, +-1 lines =@@ --a.ts(1,8): error TS1192: Module '"b"' has no default export. -- -- --==== a.ts (1 errors) ==== -- import Namespace from "./b"; -- ~~~~~~~~~ --!!! error TS1192: Module '"b"' has no default export. -- export var x = new Namespace.Foo(); -- --==== b.ts (0 errors) ==== -- export class Foo { -- member: string; -- } -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt new file mode 100644 index 0000000000..2a76c2fb07 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt @@ -0,0 +1,27 @@ +service.ts(1,8): error TS2613: Module '"db"' has no default export. Did you mean to use 'import { db } from "db"' instead? + + +==== db.ts (0 errors) ==== + export class db { + public doSomething() { + } + } + +==== service.ts (1 errors) ==== + import db from './db'; // error no default export + ~~ +!!! error TS2613: Module '"db"' has no default export. Did you mean to use 'import { db } from "db"' instead? + function someDecorator(target) { + return target; + } + @someDecorator + class MyClass { + db: db.db; + + constructor(db: db.db) { + this.db = db; + this.db.doSomething(); + } + } + export {MyClass}; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt.diff deleted file mode 100644 index 1a566bcb4f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.decoratorMetadataWithImportDeclarationNameCollision4.errors.txt -+++ new.decoratorMetadataWithImportDeclarationNameCollision4.errors.txt -@@= skipped -0, +-1 lines =@@ --service.ts(1,8): error TS2613: Module '"db"' has no default export. Did you mean to use 'import { db } from "db"' instead? -- -- --==== db.ts (0 errors) ==== -- export class db { -- public doSomething() { -- } -- } -- --==== service.ts (1 errors) ==== -- import db from './db'; // error no default export -- ~~ --!!! error TS2613: Module '"db"' has no default export. Did you mean to use 'import { db } from "db"' instead? -- function someDecorator(target) { -- return target; -- } -- @someDecorator -- class MyClass { -- db: db.db; -- -- constructor(db: db.db) { -- this.db = db; -- this.db.doSomething(); -- } -- } -- export {MyClass}; -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types index 104b75a61b..08050d5338 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types @@ -27,19 +27,19 @@ class MyClass { >MyClass : MyClass db: db.db; ->db : error +>db : db >db : any constructor(db: db.db) { ->db : error +>db : db >db : any this.db = db; ->this.db = db : error ->this.db : error +>this.db = db : db +>this.db : db >this : this >db : db ->db : error +>db : db this.db.doSomething(); >this.db.doSomething() : any diff --git a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types.diff b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types.diff index 5dbe525d0f..9fda973323 100644 --- a/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types.diff +++ b/testdata/baselines/reference/submodule/compiler/decoratorMetadataWithImportDeclarationNameCollision4.types.diff @@ -5,24 +5,24 @@ db: db.db; ->db : db.db -+>db : error ++>db : db >db : any constructor(db: db.db) { ->db : db.db -+>db : error ++>db : db >db : any this.db = db; ->this.db = db : db.db ->this.db : db.db -+>this.db = db : error -+>this.db : error ++>this.db = db : db ++>this.db : db >this : this ->db : db.db ->db : db.db +>db : db -+>db : error ++>db : db this.db.doSomething(); >this.db.doSomething() : any diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt new file mode 100644 index 0000000000..c53ed78c6e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt @@ -0,0 +1,42 @@ +client.ts(1,8): error TS1192: Module '"server"' has no default export. +client.ts(2,8): error TS1192: Module '"server"' has no default export. +client.ts(4,8): error TS1192: Module '"server"' has no default export. +client.ts(6,8): error TS1192: Module '"server"' has no default export. +client.ts(9,8): error TS1192: Module '"server"' has no default export. +client.ts(11,8): error TS1192: Module '"server"' has no default export. + + +==== server.ts (0 errors) ==== + export class a { } + export class x { } + export class m { } + export class a11 { } + export class a12 { } + export class x11 { } + +==== client.ts (6 errors) ==== + import defaultBinding1, { } from "./server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. + import defaultBinding2, { a } from "./server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. + export var x1 = new a(); + import defaultBinding3, { a11 as b } from "./server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. + export var x2 = new b(); + import defaultBinding4, { x, a12 as y } from "./server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. + export var x4 = new x(); + export var x5 = new y(); + import defaultBinding5, { x11 as z, } from "./server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. + export var x3 = new z(); + import defaultBinding6, { m, } from "./server"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. + export var x6 = new m(); + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt.diff deleted file mode 100644 index f0324a5d95..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamedImportDts.errors.txt -@@= skipped -0, +-1 lines =@@ --client.ts(1,8): error TS1192: Module '"server"' has no default export. --client.ts(2,8): error TS1192: Module '"server"' has no default export. --client.ts(4,8): error TS1192: Module '"server"' has no default export. --client.ts(6,8): error TS1192: Module '"server"' has no default export. --client.ts(9,8): error TS1192: Module '"server"' has no default export. --client.ts(11,8): error TS1192: Module '"server"' has no default export. -- -- --==== server.ts (0 errors) ==== -- export class a { } -- export class x { } -- export class m { } -- export class a11 { } -- export class a12 { } -- export class x11 { } -- --==== client.ts (6 errors) ==== -- import defaultBinding1, { } from "./server"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. -- import defaultBinding2, { a } from "./server"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. -- export var x1 = new a(); -- import defaultBinding3, { a11 as b } from "./server"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. -- export var x2 = new b(); -- import defaultBinding4, { x, a12 as y } from "./server"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. -- export var x4 = new x(); -- export var x5 = new y(); -- import defaultBinding5, { x11 as z, } from "./server"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. -- export var x3 = new z(); -- import defaultBinding6, { m, } from "./server"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. -- export var x6 = new m(); -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt new file mode 100644 index 0000000000..1b19987c9e --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt @@ -0,0 +1,39 @@ +es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(2,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(4,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(6,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(9,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. +es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(11,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. + + +==== es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.ts (0 errors) ==== + export var a = 10; + export var x = a; + export var m = a; + +==== es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts (6 errors) ==== + import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. + import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. + var x1: number = a; + import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. + var x1: number = b; + import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. + var x1: number = x; + var x1: number = y; + import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. + var x1: number = z; + import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; + ~~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. + var x1: number = m; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt.diff deleted file mode 100644 index 8a322c119f..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt.diff +++ /dev/null @@ -1,44 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamedImportInEs5.errors.txt -@@= skipped -0, +-1 lines =@@ --es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. --es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(2,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. --es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(4,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. --es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(6,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. --es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(9,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. --es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts(11,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. -- -- --==== es6ImportDefaultBindingFollowedWithNamedImportInEs5_0.ts (0 errors) ==== -- export var a = 10; -- export var x = a; -- export var m = a; -- --==== es6ImportDefaultBindingFollowedWithNamedImportInEs5_1.ts (6 errors) ==== -- import defaultBinding1, { } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. -- import defaultBinding2, { a } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. -- var x1: number = a; -- import defaultBinding3, { a as b } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. -- var x1: number = b; -- import defaultBinding4, { x, a as y } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. -- var x1: number = x; -- var x1: number = y; -- import defaultBinding5, { x as z, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. -- var x1: number = z; -- import defaultBinding6, { m, } from "./es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"; -- ~~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamedImportInEs5_0"' has no default export. -- var x1: number = m; -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt new file mode 100644 index 0000000000..5bc817bf2d --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt @@ -0,0 +1,11 @@ +client.ts(1,8): error TS1192: Module '"server"' has no default export. + + +==== server.ts (0 errors) ==== + export class a { } + +==== client.ts (1 errors) ==== + import defaultBinding, * as nameSpaceBinding from "./server"; + ~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. + export var x = new nameSpaceBinding.a(); \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt.diff deleted file mode 100644 index ddc8743b67..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBindingDts.errors.txt -@@= skipped -0, +-1 lines =@@ --client.ts(1,8): error TS1192: Module '"server"' has no default export. -- -- --==== server.ts (0 errors) ==== -- export class a { } -- --==== client.ts (1 errors) ==== -- import defaultBinding, * as nameSpaceBinding from "./server"; -- ~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. -- export var x = new nameSpaceBinding.a(); -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt new file mode 100644 index 0000000000..f3ffd2efcc --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt @@ -0,0 +1,11 @@ +es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. + + +==== es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts (0 errors) ==== + export var a = 10; + +==== es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts (1 errors) ==== + import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; + ~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. + var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt.diff deleted file mode 100644 index 649a0b6b8a..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5.errors.txt -@@= skipped -0, +-1 lines =@@ --es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. -- -- --==== es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0.ts (0 errors) ==== -- export var a = 10; -- --==== es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_1.ts (1 errors) ==== -- import defaultBinding, * as nameSpaceBinding from "./es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"; -- ~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingFollowedWithNamespaceBindingInEs5_0"' has no default export. -- var x: number = nameSpaceBinding.a; -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt index b71883daa8..b1ae69dbfe 100644 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt @@ -1,11 +1,14 @@ client.ts(1,1): error TS1191: An import declaration cannot have modifiers. +client.ts(1,15): error TS1192: Module '"server"' has no default export. ==== server.ts (0 errors) ==== export var a = 10; -==== client.ts (1 errors) ==== +==== client.ts (2 errors) ==== export import defaultBinding, * as nameSpaceBinding from "./server"; ~~~~~~ !!! error TS1191: An import declaration cannot have modifiers. + ~~~~~~~~~~~~~~ +!!! error TS1192: Module '"server"' has no default export. export var x: number = nameSpaceBinding.a; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt.diff deleted file mode 100644 index fe067b7a5c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt.diff +++ /dev/null @@ -1,18 +0,0 @@ ---- old.es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt -+++ new.es6ImportDefaultBindingFollowedWithNamespaceBindingWithExport.errors.txt -@@= skipped -0, +0 lines =@@ - client.ts(1,1): error TS1191: An import declaration cannot have modifiers. --client.ts(1,15): error TS1192: Module '"server"' has no default export. - - - ==== server.ts (0 errors) ==== - export var a = 10; - --==== client.ts (2 errors) ==== -+==== client.ts (1 errors) ==== - export import defaultBinding, * as nameSpaceBinding from "./server"; - ~~~~~~ - !!! error TS1191: An import declaration cannot have modifiers. -- ~~~~~~~~~~~~~~ --!!! error TS1192: Module '"server"' has no default export. - export var x: number = nameSpaceBinding.a; diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingNoDefaultProperty.errors.txt b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingNoDefaultProperty.errors.txt new file mode 100644 index 0000000000..b549112209 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingNoDefaultProperty.errors.txt @@ -0,0 +1,11 @@ +es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. + + +==== es6ImportDefaultBindingNoDefaultProperty_0.ts (0 errors) ==== + export var a = 10; + +==== es6ImportDefaultBindingNoDefaultProperty_1.ts (1 errors) ==== + import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; + ~~~~~~~~~~~~~~ +!!! error TS1192: Module '"es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingNoDefaultProperty.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingNoDefaultProperty.errors.txt.diff deleted file mode 100644 index 8b6493db38..0000000000 --- a/testdata/baselines/reference/submodule/compiler/es6ImportDefaultBindingNoDefaultProperty.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.es6ImportDefaultBindingNoDefaultProperty.errors.txt -+++ new.es6ImportDefaultBindingNoDefaultProperty.errors.txt -@@= skipped -0, +-1 lines =@@ --es6ImportDefaultBindingNoDefaultProperty_1.ts(1,8): error TS1192: Module '"es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. -- -- --==== es6ImportDefaultBindingNoDefaultProperty_0.ts (0 errors) ==== -- export var a = 10; -- --==== es6ImportDefaultBindingNoDefaultProperty_1.ts (1 errors) ==== -- import defaultBinding from "./es6ImportDefaultBindingNoDefaultProperty_0"; -- ~~~~~~~~~~~~~~ --!!! error TS1192: Module '"es6ImportDefaultBindingNoDefaultProperty_0"' has no default export. -- -@@= skipped --1, +1 lines =@@ -+ diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt b/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt index 923dd9d79c..b388e239a9 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt @@ -1,10 +1,13 @@ +src/foo.mts(1,8): error TS1192: Module '"src/a"' has no default export. src/foo.mts(6,4): error TS2339: Property 'default' does not exist on type 'typeof import("src/a")'. ==== src/a.cts (0 errors) ==== export const a: number = 1; -==== src/foo.mts (1 errors) ==== +==== src/foo.mts (2 errors) ==== import d, {a} from './a.cjs'; + ~ +!!! error TS1192: Module '"src/a"' has no default export. import * as ns from './a.cjs'; export {d, a, ns}; diff --git a/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt.diff index c67065f5b1..e473595a67 100644 --- a/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/nodeNextCjsNamespaceImportDefault1.errors.txt.diff @@ -3,13 +3,16 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ ++src/foo.mts(1,8): error TS1192: Module '"src/a"' has no default export. +src/foo.mts(6,4): error TS2339: Property 'default' does not exist on type 'typeof import("src/a")'. + + +==== src/a.cts (0 errors) ==== + export const a: number = 1; -+==== src/foo.mts (1 errors) ==== ++==== src/foo.mts (2 errors) ==== + import d, {a} from './a.cjs'; ++ ~ ++!!! error TS1192: Module '"src/a"' has no default export. + import * as ns from './a.cjs'; + export {d, a, ns}; + diff --git a/testdata/baselines/reference/submodule/conformance/exportStar-amd.errors.txt b/testdata/baselines/reference/submodule/conformance/exportStar-amd.errors.txt index d5e0a77d32..4402aed8a5 100644 --- a/testdata/baselines/reference/submodule/conformance/exportStar-amd.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportStar-amd.errors.txt @@ -1,3 +1,4 @@ +main.ts(1,8): error TS1192: Module '"t4"' has no default export. t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. @@ -25,8 +26,11 @@ t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. -==== main.ts (0 errors) ==== +==== main.ts (1 errors) ==== import hello, { x, y, z, foo } from "./t4"; + ~~~~~ +!!! error TS1192: Module '"t4"' has no default export. +!!! related TS1195 t4.ts:2:1: 'export *' does not re-export a default. hello; x; y; diff --git a/testdata/baselines/reference/submodule/conformance/exportStar-amd.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/exportStar-amd.errors.txt.diff deleted file mode 100644 index be66280602..0000000000 --- a/testdata/baselines/reference/submodule/conformance/exportStar-amd.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.exportStar-amd.errors.txt -+++ new.exportStar-amd.errors.txt -@@= skipped -0, +0 lines =@@ --main.ts(1,8): error TS1192: Module '"t4"' has no default export. - t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. - t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. - -@@= skipped -25, +24 lines =@@ - ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. - --==== main.ts (1 errors) ==== -+==== main.ts (0 errors) ==== - import hello, { x, y, z, foo } from "./t4"; -- ~~~~~ --!!! error TS1192: Module '"t4"' has no default export. --!!! related TS1195 t4.ts:2:1: 'export *' does not re-export a default. - hello; - x; - y; diff --git a/testdata/baselines/reference/submodule/conformance/exportStar.errors.txt b/testdata/baselines/reference/submodule/conformance/exportStar.errors.txt index d5e0a77d32..4402aed8a5 100644 --- a/testdata/baselines/reference/submodule/conformance/exportStar.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/exportStar.errors.txt @@ -1,3 +1,4 @@ +main.ts(1,8): error TS1192: Module '"t4"' has no default export. t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. @@ -25,8 +26,11 @@ t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. -==== main.ts (0 errors) ==== +==== main.ts (1 errors) ==== import hello, { x, y, z, foo } from "./t4"; + ~~~~~ +!!! error TS1192: Module '"t4"' has no default export. +!!! related TS1195 t4.ts:2:1: 'export *' does not re-export a default. hello; x; y; diff --git a/testdata/baselines/reference/submodule/conformance/exportStar.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/exportStar.errors.txt.diff deleted file mode 100644 index d7aa137077..0000000000 --- a/testdata/baselines/reference/submodule/conformance/exportStar.errors.txt.diff +++ /dev/null @@ -1,20 +0,0 @@ ---- old.exportStar.errors.txt -+++ new.exportStar.errors.txt -@@= skipped -0, +0 lines =@@ --main.ts(1,8): error TS1192: Module '"t4"' has no default export. - t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'x'. Consider explicitly re-exporting to resolve the ambiguity. - t4.ts(3,1): error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. - -@@= skipped -25, +24 lines =@@ - ~~~~~~~~~~~~~~~~~~~~~ - !!! error TS2308: Module "./t1" has already exported a member named 'y'. Consider explicitly re-exporting to resolve the ambiguity. - --==== main.ts (1 errors) ==== -+==== main.ts (0 errors) ==== - import hello, { x, y, z, foo } from "./t4"; -- ~~~~~ --!!! error TS1192: Module '"t4"' has no default export. --!!! related TS1195 t4.ts:2:1: 'export *' does not re-export a default. - hello; - x; - y; diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1.errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1.errors.txt index 9a29c26bee..e66f3db853 100644 --- a/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCJSEmit1.errors.txt @@ -2,6 +2,7 @@ /2.cjs(1,1): error TS2304: Cannot find name 'exports'. /3.cjs(2,1): error TS2304: Cannot find name 'exports'. /5.cjs(1,17): error TS2306: File '/2.cjs' is not a module. +/5.cjs(2,8): error TS1192: Module '"/3"' has no default export. ==== /1.cjs (1 errors) ==== @@ -23,11 +24,13 @@ ==== /4.cjs (0 errors) ==== ; -==== /5.cjs (1 errors) ==== +==== /5.cjs (2 errors) ==== import two from "./2.cjs"; // ok ~~~~~~~~~ !!! error TS2306: File '/2.cjs' is not a module. import three from "./3.cjs"; // error + ~~~~~ +!!! error TS1192: Module '"/3"' has no default export. two.foo; three.foo; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt new file mode 100644 index 0000000000..81e9b943c0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt @@ -0,0 +1,22 @@ +index.ts(2,8): error TS1192: Module '"subfolder/index"' has no default export. + + +==== subfolder/index.ts (0 errors) ==== + // cjs format file + export const a = 1; +==== index.ts (1 errors) ==== + // esm format file + import mod from "./subfolder/index.js"; + ~~~ +!!! error TS1192: Module '"subfolder/index"' has no default export. + mod; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt.diff new file mode 100644 index 0000000000..198e05b67f --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt.diff @@ -0,0 +1,27 @@ +--- old.nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt ++++ new.nodeModulesCjsFormatFileAlwaysHasDefault(module=node16).errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.ts(2,8): error TS1192: Module '"subfolder/index"' has no default export. ++ ++ ++==== subfolder/index.ts (0 errors) ==== ++ // cjs format file ++ export const a = 1; ++==== index.ts (1 errors) ==== ++ // esm format file ++ import mod from "./subfolder/index.js"; ++ ~~~ ++!!! error TS1192: Module '"subfolder/index"' has no default export. ++ mod; ++==== package.json (0 errors) ==== ++ { ++ "name": "package", ++ "private": true, ++ "type": "module" ++ } ++==== subfolder/package.json (0 errors) ==== ++ { ++ "type": "commonjs" ++ } diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt new file mode 100644 index 0000000000..81e9b943c0 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt @@ -0,0 +1,22 @@ +index.ts(2,8): error TS1192: Module '"subfolder/index"' has no default export. + + +==== subfolder/index.ts (0 errors) ==== + // cjs format file + export const a = 1; +==== index.ts (1 errors) ==== + // esm format file + import mod from "./subfolder/index.js"; + ~~~ +!!! error TS1192: Module '"subfolder/index"' has no default export. + mod; +==== package.json (0 errors) ==== + { + "name": "package", + "private": true, + "type": "module" + } +==== subfolder/package.json (0 errors) ==== + { + "type": "commonjs" + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt.diff new file mode 100644 index 0000000000..1f02390e22 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt.diff @@ -0,0 +1,27 @@ +--- old.nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt ++++ new.nodeModulesCjsFormatFileAlwaysHasDefault(module=nodenext).errors.txt +@@= skipped -0, +-1 lines =@@ +- +@@= skipped --1, +1 lines =@@ ++index.ts(2,8): error TS1192: Module '"subfolder/index"' has no default export. ++ ++ ++==== subfolder/index.ts (0 errors) ==== ++ // cjs format file ++ export const a = 1; ++==== index.ts (1 errors) ==== ++ // esm format file ++ import mod from "./subfolder/index.js"; ++ ~~~ ++!!! error TS1192: Module '"subfolder/index"' has no default export. ++ mod; ++==== package.json (0 errors) ==== ++ { ++ "name": "package", ++ "private": true, ++ "type": "module" ++ } ++==== subfolder/package.json (0 errors) ==== ++ { ++ "type": "commonjs" ++ } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesCJSEmit1.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesCJSEmit1.errors.txt.diff index 636869bd89..e90ead308e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesCJSEmit1.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/nodeModulesCJSEmit1.errors.txt.diff @@ -4,8 +4,8 @@ +/1.cjs(1,1): error TS2580: Cannot find name 'module'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node`. +/2.cjs(1,1): error TS2304: Cannot find name 'exports'. /3.cjs(2,1): error TS2304: Cannot find name 'exports'. --/5.cjs(2,8): error TS1192: Module '"/3"' has no default export. +/5.cjs(1,17): error TS2306: File '/2.cjs' is not a module. + /5.cjs(2,8): error TS1192: Module '"/3"' has no default export. -==== /1.cjs (0 errors) ==== @@ -22,15 +22,15 @@ ==== /3.cjs (1 errors) ==== import "foo"; -@@= skipped -18, +24 lines =@@ +@@= skipped -16, +23 lines =@@ + ==== /4.cjs (0 errors) ==== + ; - ==== /5.cjs (1 errors) ==== +-==== /5.cjs (1 errors) ==== ++==== /5.cjs (2 errors) ==== import two from "./2.cjs"; // ok + ~~~~~~~~~ +!!! error TS2306: File '/2.cjs' is not a module. import three from "./3.cjs"; // error -- ~~~~~ --!!! error TS1192: Module '"/3"' has no default export. - two.foo; - three.foo; - + ~~~~~ + !!! error TS1192: Module '"/3"' has no default export.