diff --git a/internal/checker/checker.go b/internal/checker/checker.go index c9bb8dabd7..f39c150577 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -5539,7 +5539,7 @@ func (c *Checker) checkExternalModuleExports(node *ast.Node) { links := c.moduleSymbolLinks.Get(moduleSymbol) if !links.exportsChecked { exportEqualsSymbol := moduleSymbol.Exports[ast.InternalSymbolNameExportEquals] - if exportEqualsSymbol != nil && c.hasExportedMembers(moduleSymbol) { + if exportEqualsSymbol != nil && c.hasExportedMembers(moduleSymbol, exportEqualsSymbol.ValueDeclaration.Kind == ast.KindJSExportAssignment) { declaration := core.OrElse(c.getDeclarationOfAliasSymbol(exportEqualsSymbol), exportEqualsSymbol.ValueDeclaration) if declaration != nil && !isTopLevelInExternalModuleAugmentation(declaration) { c.error(declaration, diagnostics.An_export_assignment_cannot_be_used_in_a_module_with_other_exported_elements) @@ -5575,10 +5575,17 @@ func (c *Checker) checkExternalModuleExports(node *ast.Node) { } } -func (c *Checker) hasExportedMembers(moduleSymbol *ast.Symbol) bool { +func (c *Checker) hasExportedMembers(moduleSymbol *ast.Symbol, isCommonJS bool) bool { for id := range moduleSymbol.Exports { if id != ast.InternalSymbolNameExportEquals { - return true + if !isCommonJS { + return true + } + for _, declaration := range moduleSymbol.Exports[id].Declarations { + if declaration.Kind != ast.KindJSTypeAliasDeclaration { + return true + } + } } } return false @@ -15333,13 +15340,27 @@ func (c *Checker) resolveEntityName(name *ast.Node, meaning ast.SymbolFlags, ign if resolveLocation == nil { resolveLocation = name } - symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/)) + if meaning == ast.SymbolFlagsNamespace { + symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, nil, true /*isUse*/, false /*excludeGlobals*/)) + if symbol == nil { + alias := c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), ast.SymbolFlagsAlias, nil, true /*isUse*/, false /*excludeGlobals*/)) + if alias != nil && alias.Name == ast.InternalSymbolNameExportEquals { + // resolve typedefs exported from commonjs, stored on the module symbol + symbol = alias.Parent + } + } + if symbol == nil && message != nil { + c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/) + } + } else { + symbol = c.getMergedSymbol(c.resolveName(resolveLocation, name.Text(), meaning, message, true /*isUse*/, false /*excludeGlobals*/)) + } case ast.KindQualifiedName: qualified := name.AsQualifiedName() - symbol = c.resolveQualifiedName(name, qualified.Left, qualified.Right, meaning, ignoreErrors, dontResolveAlias, location) + symbol = c.resolveQualifiedName(name, qualified.Left, qualified.Right, meaning, ignoreErrors, location) case ast.KindPropertyAccessExpression: access := name.AsPropertyAccessExpression() - symbol = c.resolveQualifiedName(name, access.Expression, access.Name(), meaning, ignoreErrors, dontResolveAlias, location) + symbol = c.resolveQualifiedName(name, access.Expression, access.Name(), meaning, ignoreErrors, location) default: panic("Unknown entity name kind") } @@ -15357,7 +15378,7 @@ func (c *Checker) resolveEntityName(name *ast.Node, meaning ast.SymbolFlags, ign return symbol } -func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *ast.Node, meaning ast.SymbolFlags, ignoreErrors bool, dontResolveAlias bool, location *ast.Node) *ast.Symbol { +func (c *Checker) resolveQualifiedName(name *ast.Node, left *ast.Node, right *ast.Node, meaning ast.SymbolFlags, ignoreErrors bool, location *ast.Node) *ast.Symbol { namespace := c.resolveEntityName(left, ast.SymbolFlagsNamespace, ignoreErrors, false /*dontResolveAlias*/, location) if namespace == nil || ast.NodeIsMissing(right) { return nil @@ -15713,12 +15734,26 @@ func (c *Checker) getExportsOfModuleWorker(moduleSymbol *ast.Symbol) (exports as } return symbols } + var originalModule *ast.Symbol + if moduleSymbol != nil { + if c.resolveSymbolEx(moduleSymbol.Exports[ast.InternalSymbolNameExportEquals], false /*dontResolveAlias*/) != nil { + originalModule = moduleSymbol + } + } // A module defined by an 'export=' consists of one export that needs to be resolved moduleSymbol = c.resolveExternalModuleSymbol(moduleSymbol, false /*dontResolveAlias*/) exports = visit(moduleSymbol, nil, false) if exports == nil { exports = make(ast.SymbolTable) } + // A CommonJS module defined by an 'export=' might also export typedefs, stored on the original module + if originalModule != nil && len(originalModule.Exports) > 1 { + for _, symbol := range originalModule.Exports { + if symbol.Flags&ast.SymbolFlagsType != 0 && symbol.Name != ast.InternalSymbolNameExportEquals && exports[symbol.Name] == nil { + exports[symbol.Name] = symbol + } + } + } for name := range nonTypeOnlyNames.Keys() { delete(typeOnlyExportStarMap, name) } @@ -23972,6 +24007,13 @@ func (c *Checker) getTypeFromImportTypeNode(node *ast.Node) *Type { symbolFromVariable = c.getPropertyOfTypeEx(c.getTypeOfSymbol(mergedResolvedSymbol), current.Text(), false /*skipObjectFunctionPropertyAugment*/, true /*includeTypeOnlyMembers*/) } else { symbolFromModule = c.getSymbol(c.getExportsOfSymbol(mergedResolvedSymbol), current.Text(), meaning) + if symbolFromModule == nil { + // a CommonJS module might have typedefs exported alongside an export= + immediateModuleSymbol := c.resolveExternalModuleSymbol(innerModuleSymbol, true /*dontResolveAlias*/) + if immediateModuleSymbol != nil && core.Some(immediateModuleSymbol.Declarations, func(d *ast.Node) bool { return d.Kind == ast.KindJSExportAssignment }) { + symbolFromModule = c.getSymbol(c.getExportsOfSymbol(immediateModuleSymbol.Parent), current.Text(), meaning) + } + } } next := core.OrElse(symbolFromModule, symbolFromVariable) if next == nil { diff --git a/internal/fourslash/_scripts/failingTests.txt b/internal/fourslash/_scripts/failingTests.txt index fa8d12004d..76d4a8f894 100644 --- a/internal/fourslash/_scripts/failingTests.txt +++ b/internal/fourslash/_scripts/failingTests.txt @@ -326,7 +326,6 @@ TestIndexerReturnTypes1 TestIndirectClassInstantiation TestInstanceTypesForGenericType1 TestJavascriptModules20 -TestJavascriptModulesTypeImport TestJsDocAugments TestJsDocAugmentsAndExtends TestJsdocCallbackTag diff --git a/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go b/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go index 5ddc19a411..8a52d74992 100644 --- a/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go +++ b/internal/fourslash/tests/gen/javascriptModulesTypeImport_test.go @@ -10,7 +10,7 @@ import ( func TestJavascriptModulesTypeImport(t *testing.T) { t.Parallel() - t.Skip() + defer testutil.RecoverAndFail(t, "Panic on fourslash test") const content = `// @allowJs: true // @Filename: types.js diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.js b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.js new file mode 100644 index 0000000000..16af97d07e --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts] //// + +//// [typedefModuleExportsIndirect1.js] +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +module.exports = dummy; +//// [use.js] +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c + + +//// [typedefModuleExportsIndirect1.js] +"use strict"; +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +module.exports = dummy; +//// [use.js] +"use strict"; +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c; + + +//// [typedefModuleExportsIndirect1.d.ts] +export type C = { + a: 1; + m: 1; +}; +export = dummy; +//// [use.d.ts] +type C = import('./typedefModuleExportsIndirect1').C; +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +declare var c: C; + + +//// [DtsFileErrors] + + +dist/typedefModuleExportsIndirect1.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +dist/typedefModuleExportsIndirect1.d.ts(5,10): error TS2304: Cannot find name 'dummy'. +dist/use.d.ts(1,52): error TS2694: Namespace 'unknown' has no exported member 'C'. + + +==== dist/typedefModuleExportsIndirect1.d.ts (2 errors) ==== + export type C = { + a: 1; + m: 1; + }; + export = dummy; + ~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~~~~~ +!!! error TS2304: Cannot find name 'dummy'. + +==== dist/use.d.ts (1 errors) ==== + type C = import('./typedefModuleExportsIndirect1').C; + ~ +!!! error TS2694: Namespace 'unknown' has no exported member 'C'. + /** @typedef {import('./typedefModuleExportsIndirect1').C} C */ + /** @type {C} */ + declare var c: C; + \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.symbols b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.symbols new file mode 100644 index 0000000000..cc609e1896 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts] //// + +=== typedefModuleExportsIndirect1.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +>dummy : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) + +module.exports = dummy; +>module.exports : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) +>module : Symbol("typedefModuleExportsIndirect1", Decl(typedefModuleExportsIndirect1.js, 0, 0)) +>exports : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) +>dummy : Symbol(dummy, Decl(typedefModuleExportsIndirect1.js, 1, 5)) + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c +>c : Symbol(c, Decl(use.js, 2, 3)) + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.types b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.types new file mode 100644 index 0000000000..314c92c037 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect1.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts] //// + +=== typedefModuleExportsIndirect1.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +>dummy : 0 +>0 : 0 + +module.exports = dummy; +>module.exports = dummy : 0 +>module.exports : 0 +>module : { readonly dummy: 0; } +>exports : 0 +>dummy : 0 + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c +>c : import("typedefModuleExportsIndirect1").C + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.js b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.js new file mode 100644 index 0000000000..0d5492f3e3 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts] //// + +//// [typedefModuleExportsIndirect2.js] +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function() {}; +module.exports = f; +//// [use.js] +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c + + +//// [typedefModuleExportsIndirect2.js] +"use strict"; +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function () { }; +module.exports = f; +//// [use.js] +"use strict"; +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c; + + +//// [typedefModuleExportsIndirect2.d.ts] +export type C = { + a: 1; + m: 1; +}; +export = f; +//// [use.d.ts] +type C = import('./typedefModuleExportsIndirect2').C; +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +declare var c: C; + + +//// [DtsFileErrors] + + +dist/typedefModuleExportsIndirect2.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +dist/typedefModuleExportsIndirect2.d.ts(5,10): error TS2304: Cannot find name 'f'. +dist/use.d.ts(1,52): error TS2694: Namespace 'unknown' has no exported member 'C'. + + +==== dist/typedefModuleExportsIndirect2.d.ts (2 errors) ==== + export type C = { + a: 1; + m: 1; + }; + export = f; + ~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~ +!!! error TS2304: Cannot find name 'f'. + +==== dist/use.d.ts (1 errors) ==== + type C = import('./typedefModuleExportsIndirect2').C; + ~ +!!! error TS2694: Namespace 'unknown' has no exported member 'C'. + /** @typedef {import('./typedefModuleExportsIndirect2').C} C */ + /** @type {C} */ + declare var c: C; + \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.symbols b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.symbols new file mode 100644 index 0000000000..66b77d9c1b --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts] //// + +=== typedefModuleExportsIndirect2.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function() {}; +>f : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) + +module.exports = f; +>module.exports : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) +>module : Symbol("typedefModuleExportsIndirect2", Decl(typedefModuleExportsIndirect2.js, 0, 0)) +>exports : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) +>f : Symbol(f, Decl(typedefModuleExportsIndirect2.js, 1, 5)) + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c +>c : Symbol(c, Decl(use.js, 2, 3)) + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.types b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.types new file mode 100644 index 0000000000..979ef24238 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect2.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts] //// + +=== typedefModuleExportsIndirect2.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function() {}; +>f : () => void +>function() {} : () => void + +module.exports = f; +>module.exports = f : () => void +>module.exports : () => void +>module : { readonly f: () => void; } +>exports : () => void +>f : () => void + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c +>c : import("typedefModuleExportsIndirect2").C + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.js b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.js new file mode 100644 index 0000000000..2daa007515 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.js @@ -0,0 +1,64 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts] //// + +//// [typedefModuleExportsIndirect3.js] +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +module.exports = o; +//// [use.js] +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c + + +//// [typedefModuleExportsIndirect3.js] +"use strict"; +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +module.exports = o; +//// [use.js] +"use strict"; +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c; + + +//// [typedefModuleExportsIndirect3.d.ts] +export type C = { + a: 1; + m: 1; +}; +export = o; +//// [use.d.ts] +type C = import('./typedefModuleExportsIndirect3').C; +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +declare var c: C; + + +//// [DtsFileErrors] + + +dist/typedefModuleExportsIndirect3.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +dist/typedefModuleExportsIndirect3.d.ts(5,10): error TS2304: Cannot find name 'o'. +dist/use.d.ts(1,52): error TS2694: Namespace 'unknown' has no exported member 'C'. + + +==== dist/typedefModuleExportsIndirect3.d.ts (2 errors) ==== + export type C = { + a: 1; + m: 1; + }; + export = o; + ~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~ +!!! error TS2304: Cannot find name 'o'. + +==== dist/use.d.ts (1 errors) ==== + type C = import('./typedefModuleExportsIndirect3').C; + ~ +!!! error TS2694: Namespace 'unknown' has no exported member 'C'. + /** @typedef {import('./typedefModuleExportsIndirect3').C} C */ + /** @type {C} */ + declare var c: C; + \ No newline at end of file diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.symbols b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.symbols new file mode 100644 index 0000000000..0f1a451f01 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.symbols @@ -0,0 +1,19 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts] //// + +=== typedefModuleExportsIndirect3.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +>o : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) + +module.exports = o; +>module.exports : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) +>module : Symbol("typedefModuleExportsIndirect3", Decl(typedefModuleExportsIndirect3.js, 0, 0)) +>exports : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) +>o : Symbol(o, Decl(typedefModuleExportsIndirect3.js, 1, 5)) + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c +>c : Symbol(c, Decl(use.js, 2, 3)) + diff --git a/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.types b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.types new file mode 100644 index 0000000000..be9e0ac169 --- /dev/null +++ b/testdata/baselines/reference/conformance/typedefModuleExportsIndirect3.types @@ -0,0 +1,21 @@ +//// [tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts] //// + +=== typedefModuleExportsIndirect3.js === +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +>o : {} +>{} : {} + +module.exports = o; +>module.exports = o : {} +>module.exports : {} +>module : { readonly o: {}; } +>exports : {} +>o : {} + +=== use.js === +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c +>c : import("typedefModuleExportsIndirect3").C + diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc index 479db50506..69f271dfd9 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsImportType.baseline.jsonc @@ -19,5 +19,9 @@ // === findAllReferences === +// === /a.js === +// module.exports = 0; +// export type [|N|] = number; + // === /b.js === -// type T = import("./a")./*FIND ALL REFS*/N; \ No newline at end of file +// type T = import("./a")./*FIND ALL REFS*/[|N|]; \ No newline at end of file diff --git a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc index d58e4feb85..92b33590b7 100644 --- a/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc +++ b/testdata/baselines/reference/fourslash/findAllReferences/findAllRefsTypedef_importType.baseline.jsonc @@ -19,6 +19,11 @@ // === findAllReferences === +// === /a.js === +// module.exports = 0; +// /** @typedef {number} [|Foo|] */ +// const dummy = 0; + // === /b.js === -// /** @type {import('./a')./*FIND ALL REFS*/Foo} */ +// /** @type {import('./a')./*FIND ALL REFS*/[|Foo|]} */ // const x = 0; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt deleted file mode 100644 index 855d7577c6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt +++ /dev/null @@ -1,21 +0,0 @@ -something.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== file.ts (0 errors) ==== - class Foo { - x: number; - } - - declare global { - var module: any; // Just here to remove unrelated error from test - } - - export = Foo; -==== something.js (1 errors) ==== - /** @typedef {typeof import("./file")} Foo */ - - /** @typedef {(foo: Foo) => string} FooFun */ - - module.exports = /** @type {FooFun} */(void 0); - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff deleted file mode 100644 index af290d6fc7..0000000000 --- a/testdata/baselines/reference/submodule/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.checkJsTypeDefNoUnusedLocalMarked.errors.txt -+++ new.checkJsTypeDefNoUnusedLocalMarked.errors.txt -@@= skipped -0, +0 lines =@@ -- -+something.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== file.ts (0 errors) ==== -+ class Foo { -+ x: number; -+ } -+ -+ declare global { -+ var module: any; // Just here to remove unrelated error from test -+ } -+ -+ export = Foo; -+==== something.js (1 errors) ==== -+ /** @typedef {typeof import("./file")} Foo */ -+ -+ /** @typedef {(foo: Foo) => string} FooFun */ -+ -+ module.exports = /** @type {FooFun} */(void 0); -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt deleted file mode 100644 index 267621261d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt +++ /dev/null @@ -1,61 +0,0 @@ -input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== input.js (1 errors) ==== - /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ - - /** - * @template P - * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ - - /** - * @type {StatelessComponent} - */ - const MyComponent = () => /* @type {any} */(null); - - MyComponent.defaultProps = { - color: "red" - }; - - const MyComponent2 = () => null; - - /** - * @type {MyComponentProps} - */ - MyComponent2.defaultProps = { - color: "red" - } - - /** - * @type {StatelessComponent} - */ - const check = MyComponent2; - - /** - * - * @param {{ props: MyComponentProps }} p - */ - function expectLiteral(p) {} - - function foo() { - /** - * @type {MyComponentProps} - */ - this.props = { color: "red" }; - - expectLiteral(this); - } - - /** - * @type {MyComponentProps} - */ - module.exports = { - ~~~~~~~~~~~~~~~~~~ - color: "red" - ~~~~~~~~~~~~~~~~ - } - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - - expectLiteral({ props: module.exports }); - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt.diff deleted file mode 100644 index 6569dcf3a6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt.diff +++ /dev/null @@ -1,65 +0,0 @@ ---- old.expandoFunctionContextualTypesJs.errors.txt -+++ new.expandoFunctionContextualTypesJs.errors.txt -@@= skipped -0, +0 lines =@@ -- -+input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== input.js (1 errors) ==== -+ /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ -+ -+ /** -+ * @template P -+ * @typedef {{ (): any; defaultProps?: Partial

}} StatelessComponent */ -+ -+ /** -+ * @type {StatelessComponent} -+ */ -+ const MyComponent = () => /* @type {any} */(null); -+ -+ MyComponent.defaultProps = { -+ color: "red" -+ }; -+ -+ const MyComponent2 = () => null; -+ -+ /** -+ * @type {MyComponentProps} -+ */ -+ MyComponent2.defaultProps = { -+ color: "red" -+ } -+ -+ /** -+ * @type {StatelessComponent} -+ */ -+ const check = MyComponent2; -+ -+ /** -+ * -+ * @param {{ props: MyComponentProps }} p -+ */ -+ function expectLiteral(p) {} -+ -+ function foo() { -+ /** -+ * @type {MyComponentProps} -+ */ -+ this.props = { color: "red" }; -+ -+ expectLiteral(this); -+ } -+ -+ /** -+ * @type {MyComponentProps} -+ */ -+ module.exports = { -+ ~~~~~~~~~~~~~~~~~~ -+ color: "red" -+ ~~~~~~~~~~~~~~~~ -+ } -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ expectLiteral({ props: module.exports }); -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt index 824d5e4f6f..9da858c20f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt @@ -1,8 +1,7 @@ -index.js(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements. index.js(9,34): error TS7006: Parameter 'options' implicitly has an 'any' type. -==== index.js (2 errors) ==== +==== index.js (1 errors) ==== /** * @typedef Options * @property {string} opt @@ -12,8 +11,6 @@ index.js(9,34): error TS7006: Parameter 'options' implicitly has an 'any' type. * @param {Options} options */ module.exports = function loader(options) {} - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ~~~~~~~ !!! error TS7006: Parameter 'options' implicitly has an 'any' type. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff index 6b73aa246f..c67d7cf39f 100644 --- a/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff @@ -2,11 +2,10 @@ +++ new.jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(9,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +index.js(9,34): error TS7006: Parameter 'options' implicitly has an 'any' type. + + -+==== index.js (2 errors) ==== ++==== index.js (1 errors) ==== + /** + * @typedef Options + * @property {string} opt @@ -16,8 +15,6 @@ + * @param {Options} options + */ + module.exports = function loader(options) {} -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~~~~~~~ +!!! error TS7006: Parameter 'options' implicitly has an 'any' type. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt b/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt deleted file mode 100644 index 3d859304e6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt +++ /dev/null @@ -1,45 +0,0 @@ -typescript-eslint.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== eslint.config.js (0 errors) ==== - const eslintReact = require('./eslint-plugin-react.js'); - const tseslint = require('./typescript-eslint.js'); - - tseslint.config(eslintReact) - -==== eslint-plugin-react.js (0 errors) ==== - const deprecatedRules = { - "jsx-sort-default-props": true - } - - const allRules = { - 'no-unsafe': true - } - - module.exports = { - plugins: { - react: { - deprecatedRules, - rules: allRules, - }, - }, - }; - -==== typescript-eslint.js (1 errors) ==== - /** - * @typedef {{ rules: Record }} Plugin - */ - - /** - * @typedef {{ plugins: Record }} Config - */ - - /** - * @type {(...configs: Config[]) => void} - */ - function config(...configs) { } - - module.exports = { config }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff deleted file mode 100644 index b30aabfac8..0000000000 --- a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff +++ /dev/null @@ -1,49 +0,0 @@ ---- old.moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt -+++ new.moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt -@@= skipped -0, +0 lines =@@ -- -+typescript-eslint.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== eslint.config.js (0 errors) ==== -+ const eslintReact = require('./eslint-plugin-react.js'); -+ const tseslint = require('./typescript-eslint.js'); -+ -+ tseslint.config(eslintReact) -+ -+==== eslint-plugin-react.js (0 errors) ==== -+ const deprecatedRules = { -+ "jsx-sort-default-props": true -+ } -+ -+ const allRules = { -+ 'no-unsafe': true -+ } -+ -+ module.exports = { -+ plugins: { -+ react: { -+ deprecatedRules, -+ rules: allRules, -+ }, -+ }, -+ }; -+ -+==== typescript-eslint.js (1 errors) ==== -+ /** -+ * @typedef {{ rules: Record }} Plugin -+ */ -+ -+ /** -+ * @typedef {{ plugins: Record }} Config -+ */ -+ -+ /** -+ * @type {(...configs: Config[]) => void} -+ */ -+ function config(...configs) { } -+ -+ module.exports = { config }; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt deleted file mode 100644 index 5a59e1a49e..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. - - -==== mod1.js (1 errors) ==== - /** @callback Con - some kind of continuation - * @param {object | undefined} error - * @return {any} I don't even know what this should return - */ - module.exports = C - ~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - function C() { - this.p = 1 - } - -==== use.js (1 errors) ==== - /** @param {import('./mod1').Con} k */ - ~~~ -!!! error TS2694: Namespace 'C' has no exported member 'Con'. - function f(k) { - if (1 === 2 - 1) { - // I guess basic math works! - } - return k({ ok: true}) - } - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt.diff deleted file mode 100644 index b3e507b55d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.callbackCrossModule.errors.txt -+++ new.callbackCrossModule.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+use.js(1,30): error TS2694: Namespace 'C' has no exported member 'Con'. -+ -+ -+==== mod1.js (1 errors) ==== -+ /** @callback Con - some kind of continuation -+ * @param {object | undefined} error -+ * @return {any} I don't even know what this should return -+ */ -+ module.exports = C -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ function C() { -+ this.p = 1 -+ } -+ -+==== use.js (1 errors) ==== -+ /** @param {import('./mod1').Con} k */ -+ ~~~ -+!!! error TS2694: Namespace 'C' has no exported member 'Con'. -+ function f(k) { -+ if (1 === 2 - 1) { -+ // I guess basic math works! -+ } -+ return k({ ok: true}) -+ } -+ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types index 675bc5286c..5b6eb1effc 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types +++ b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types @@ -26,8 +26,8 @@ function C() { === use.js === /** @param {import('./mod1').Con} k */ function f(k) { ->f : (k: any) => any ->k : any +>f : (k: import("mod1").Con) => any +>k : import("mod1").Con if (1 === 2 - 1) { >1 === 2 - 1 : boolean @@ -40,7 +40,7 @@ function f(k) { } return k({ ok: true}) >k({ ok: true}) : any ->k : any +>k : import("mod1").Con >{ ok: true} : { ok: boolean; } >ok : boolean >true : true diff --git a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types.diff b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types.diff index c2187ec482..3464d0cbe8 100644 --- a/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types.diff +++ b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types.diff @@ -32,18 +32,7 @@ /** @param {import('./mod1').Con} k */ function f(k) { ->f : (k: import("./mod1").Con) => any -->k : import("mod1").Con -+>f : (k: any) => any -+>k : any ++>f : (k: import("mod1").Con) => any + >k : import("mod1").Con - if (1 === 2 - 1) { - >1 === 2 - 1 : boolean -@@= skipped -14, +14 lines =@@ - } - return k({ ok: true}) - >k({ ok: true}) : any -->k : import("mod1").Con -+>k : any - >{ ok: true} : { ok: boolean; } - >ok : boolean - >true : true \ No newline at end of file + if (1 === 2 - 1) { \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt index 3331f7cf27..92201af30d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt @@ -1,10 +1,7 @@ context.js(4,14): error TS1340: Module './timer' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./timer')'? context.js(5,14): error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? -context.js(6,31): error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. -context.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. hook.js(2,20): error TS1340: Module './context' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./context')'? -hook.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ==== timer.js (0 errors) ==== @@ -15,7 +12,7 @@ hook.js(10,1): error TS2309: An export assignment cannot be used in a module wit this.timeout = timeout; } module.exports = Timer; -==== hook.js (2 errors) ==== +==== hook.js (1 errors) ==== /** * @typedef {(arg: import("./context")) => void} HookHandler ~~~~~~~~~~~~~~~~~~~ @@ -28,10 +25,8 @@ hook.js(10,1): error TS2309: An export assignment cannot be used in a module wit this.handle = handle; } module.exports = Hook; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== context.js (5 errors) ==== +==== context.js (3 errors) ==== /** * Imports * @@ -42,8 +37,6 @@ hook.js(10,1): error TS2309: An export assignment cannot be used in a module wit ~~~~~~~~~~~~~~~~ !!! error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? * @typedef {import("./hook").HookHandler} HookHandler - ~~~~~~~~~~~ -!!! error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. */ /** @@ -88,6 +81,4 @@ hook.js(10,1): error TS2309: An export assignment cannot be used in a module wit } } module.exports = Context; - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff index be95625d15..f81fa8ea4d 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff @@ -4,11 +4,8 @@ - +context.js(4,14): error TS1340: Module './timer' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./timer')'? +context.js(5,14): error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? -+context.js(6,31): error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. +context.js(34,14): error TS2350: Only a void function can be called with the 'new' keyword. -+context.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +hook.js(2,20): error TS1340: Module './context' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./context')'? -+hook.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== timer.js (0 errors) ==== @@ -19,7 +16,7 @@ + this.timeout = timeout; + } + module.exports = Timer; -+==== hook.js (2 errors) ==== ++==== hook.js (1 errors) ==== + /** + * @typedef {(arg: import("./context")) => void} HookHandler + ~~~~~~~~~~~~~~~~~~~ @@ -32,10 +29,8 @@ + this.handle = handle; + } + module.exports = Hook; -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== context.js (5 errors) ==== ++==== context.js (3 errors) ==== + /** + * Imports + * @@ -46,8 +41,6 @@ + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './hook' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./hook')'? + * @typedef {import("./hook").HookHandler} HookHandler -+ ~~~~~~~~~~~ -+!!! error TS2694: Namespace 'Hook' has no exported member 'HookHandler'. + */ + + /** @@ -92,6 +85,4 @@ + } + } + module.exports = Context; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js index f61783ef90..1bc0d198c0 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js @@ -186,7 +186,7 @@ declare namespace Context { * @param {HookHandler=} handle * @returns {State} */ - construct(input: Input, handle?: any): State; + construct(input: Input, handle?: import("./hook").HookHandler): State; }; } export = Context; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js.diff index 6e7301f28c..a3000e6d57 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.js.diff @@ -89,7 +89,7 @@ + * @param {HookHandler=} handle + * @returns {State} + */ -+ construct(input: Input, handle?: any): State; ++ construct(input: Input, handle?: import("./hook").HookHandler): State; + }; } -/** diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types index fbaba50105..b67917b6b4 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types @@ -80,7 +80,7 @@ module.exports = Hook; */ function Context(input) { ->Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } +>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } >input : Input if (!(this instanceof Context)) { @@ -88,11 +88,11 @@ function Context(input) { >(this instanceof Context) : boolean >this instanceof Context : boolean >this : any ->Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } +>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } return new Context(input) >new Context(input) : any ->Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } +>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } >input : Input } this.state = this.construct(input); @@ -107,11 +107,11 @@ function Context(input) { >input : Input } Context.prototype = { ->Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: any): State; } ->Context.prototype : { construct(input: Input, handle?: any): State; } ->Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ->prototype : { construct(input: Input, handle?: any): State; } ->{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: any): State; } +>Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: import("hook").HookHandler): State; } +>Context.prototype : { construct(input: Input, handle?: import("hook").HookHandler): State; } +>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } +>prototype : { construct(input: Input, handle?: import("hook").HookHandler): State; } +>{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: import("hook").HookHandler): State; } /** * @param {Input} input @@ -119,9 +119,9 @@ Context.prototype = { * @returns {State} */ construct(input, handle = () => void 0) { ->construct : (input: Input, handle?: any) => State +>construct : (input: Input, handle?: import("hook").HookHandler) => State >input : Input ->handle : any +>handle : import("hook").HookHandler >() => void 0 : () => any >void 0 : undefined >0 : 0 @@ -131,9 +131,9 @@ Context.prototype = { } } module.exports = Context; ->module.exports = Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ->module.exports : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ->module : { Context: { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; }; } ->exports : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ->Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } +>module.exports = Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } +>module.exports : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } +>module : { Context: { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; }; } +>exports : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } +>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff index 0158bec3cb..81626dc850 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff @@ -65,7 +65,7 @@ function Context(input) { ->Context : typeof Context -+>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ++>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } >input : Input if (!(this instanceof Context)) { @@ -75,13 +75,13 @@ ->this : this ->Context : typeof Context +>this : any -+>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ++>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } return new Context(input) ->new Context(input) : Context ->Context : typeof Context +>new Context(input) : any -+>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ++>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } >input : Input } this.state = this.construct(input); @@ -107,11 +107,11 @@ ->Context : typeof Context ->prototype : { construct(input: Input, handle?: HookHandler | undefined): State; } ->{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: HookHandler | undefined): State; } -+>Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: any): State; } -+>Context.prototype : { construct(input: Input, handle?: any): State; } -+>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } -+>prototype : { construct(input: Input, handle?: any): State; } -+>{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: any): State; } ++>Context.prototype = { /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: import("hook").HookHandler): State; } ++>Context.prototype : { construct(input: Input, handle?: import("hook").HookHandler): State; } ++>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } ++>prototype : { construct(input: Input, handle?: import("hook").HookHandler): State; } ++>{ /** * @param {Input} input * @param {HookHandler=} handle * @returns {State} */ construct(input, handle = () => void 0) { return input; }} : { construct(input: Input, handle?: import("hook").HookHandler): State; } /** * @param {Input} input @@ -120,13 +120,10 @@ */ construct(input, handle = () => void 0) { ->construct : (input: Input, handle?: HookHandler | undefined) => State -+>construct : (input: Input, handle?: any) => State ++>construct : (input: Input, handle?: import("hook").HookHandler) => State >input : Input -->handle : import("hook").HookHandler -+>handle : any + >handle : import("hook").HookHandler >() => void 0 : () => any - >void 0 : undefined - >0 : 0 @@= skipped -12, +12 lines =@@ } } @@ -136,8 +133,8 @@ ->module : { exports: { (input: Input): Context; new (input: Input): Context; prototype: { construct(input: Input, handle?: HookHandler | undefined): State; }; }; } ->exports : { (input: Input): Context; new (input: Input): Context; prototype: { construct(input: Input, handle?: HookHandler | undefined): State; }; } ->Context : typeof Context -+>module.exports = Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } -+>module.exports : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } -+>module : { Context: { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; }; } -+>exports : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } -+>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: any): State; }; } ++>module.exports = Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } ++>module.exports : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } ++>module : { Context: { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; }; } ++>exports : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } ++>Context : { (input: Input): any; prototype: { construct(input: Input, handle?: import("hook").HookHandler): State; }; } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt deleted file mode 100644 index 0b7c06dc92..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt +++ /dev/null @@ -1,19 +0,0 @@ -source.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== source.js (1 errors) ==== - module.exports = MyClass; - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - - function MyClass() {} - MyClass.staticMethod = function() {} - MyClass.prototype.method = function() {} - MyClass.staticProperty = 123; - - /** - * Callback to be invoked when test execution is complete. - * - * @callback DoneCB - * @param {number} failures - Number of failures that occurred. - */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff deleted file mode 100644 index bf29d0665d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsDeclarationsFunctionPrototypeStatic.errors.txt -+++ new.jsDeclarationsFunctionPrototypeStatic.errors.txt -@@= skipped -0, +0 lines =@@ -- -+source.js(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== source.js (1 errors) ==== -+ module.exports = MyClass; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ function MyClass() {} -+ MyClass.staticMethod = function() {} -+ MyClass.prototype.method = function() {} -+ MyClass.staticProperty = 123; -+ -+ /** -+ * Callback to be invoked when test execution is complete. -+ * -+ * @callback DoneCB -+ * @param {number} failures - Number of failures that occurred. -+ */ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js index 85050d43ba..eb17c3c023 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js @@ -45,3 +45,30 @@ export type DoneCB = (failures: number) => any; * @callback DoneCB * @param {number} failures - Number of failures that occurred. */ + + +//// [DtsFileErrors] + + +out/source.d.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== out/source.d.ts (1 errors) ==== + export = MyClass; + ~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + declare function MyClass(): void; + declare namespace MyClass { + var staticMethod: () => void; + } + declare namespace MyClass { + var staticProperty: number; + } + export type DoneCB = (failures: number) => any; + /** + * Callback to be invoked when test execution is complete. + * + * @callback DoneCB + * @param {number} failures - Number of failures that occurred. + */ + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff index 3a136c55f4..36259d76b8 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionPrototypeStatic.js.diff @@ -26,4 +26,31 @@ + * + * @callback DoneCB + * @param {number} failures - Number of failures that occurred. -+ */ \ No newline at end of file ++ */ ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/source.d.ts(1,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++ ++ ++==== out/source.d.ts (1 errors) ==== ++ export = MyClass; ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ++ declare function MyClass(): void; ++ declare namespace MyClass { ++ var staticMethod: () => void; ++ } ++ declare namespace MyClass { ++ var staticProperty: number; ++ } ++ export type DoneCB = (failures: number) => any; ++ /** ++ * Callback to be invoked when test execution is complete. ++ * ++ * @callback DoneCB ++ * @param {number} failures - Number of failures that occurred. ++ */ ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt index e25ccebe0d..927cd65fb6 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -7,10 +7,9 @@ file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. file2.js(6,11): error TS2315: Type 'Object' is not generic. file2.js(12,23): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. -file2.js(28,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== file2.js (4 errors) ==== +==== file2.js (3 errors) ==== const {myTypes} = require('./file.js'); /** @@ -45,8 +44,6 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi } module.exports = {testFn, testFnTypes}; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ==== file.js (6 errors) ==== /** * @namespace myTypes diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff index 516be88695..e1c0b8a4c9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff @@ -11,10 +11,9 @@ +file2.js(6,11): error TS2315: Type 'Object' is not generic. +file2.js(12,23): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being used as a namespace here. -+file2.js(28,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== file2.js (4 errors) ==== ++==== file2.js (3 errors) ==== + const {myTypes} = require('./file.js'); + + /** @@ -49,8 +48,6 @@ + } + + module.exports = {testFn, testFnTypes}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. +==== file.js (6 errors) ==== + /** + * @namespace myTypes diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt deleted file mode 100644 index 324fb0ae0d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt +++ /dev/null @@ -1,58 +0,0 @@ -mixed.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== index.js (0 errors) ==== - export {}; // flag file as module - /** - * @typedef {string | number | symbol} PropName - */ - - /** - * Callback - * - * @callback NumberToStringCb - * @param {number} a - * @returns {string} - */ - - /** - * @template T - * @typedef {T & {name: string}} MixinName - */ - - /** - * Identity function - * - * @template T - * @callback Identity - * @param {T} x - * @returns {T} - */ - -==== mixed.js (1 errors) ==== - /** - * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType - */ - /** - * @param {number} x - * @returns {SomeType} - */ - function doTheThing(x) { - return {x: ""+x}; - } - class ExportedThing { - z = "ok" - } - module.exports = { - ~~~~~~~~~~~~~~~~~~ - doTheThing, - ~~~~~~~~~~~~~~~ - ExportedThing, - ~~~~~~~~~~~~~~~~~~ - }; - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - class LocalThing { - y = "ok" - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt.diff deleted file mode 100644 index 87be54e949..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.errors.txt.diff +++ /dev/null @@ -1,62 +0,0 @@ ---- old.jsDeclarationsTypeAliases.errors.txt -+++ new.jsDeclarationsTypeAliases.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mixed.js(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== index.js (0 errors) ==== -+ export {}; // flag file as module -+ /** -+ * @typedef {string | number | symbol} PropName -+ */ -+ -+ /** -+ * Callback -+ * -+ * @callback NumberToStringCb -+ * @param {number} a -+ * @returns {string} -+ */ -+ -+ /** -+ * @template T -+ * @typedef {T & {name: string}} MixinName -+ */ -+ -+ /** -+ * Identity function -+ * -+ * @template T -+ * @callback Identity -+ * @param {T} x -+ * @returns {T} -+ */ -+ -+==== mixed.js (1 errors) ==== -+ /** -+ * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType -+ */ -+ /** -+ * @param {number} x -+ * @returns {SomeType} -+ */ -+ function doTheThing(x) { -+ return {x: ""+x}; -+ } -+ class ExportedThing { -+ z = "ok" -+ } -+ module.exports = { -+ ~~~~~~~~~~~~~~~~~~ -+ doTheThing, -+ ~~~~~~~~~~~~~~~ -+ ExportedThing, -+ ~~~~~~~~~~~~~~~~~~ -+ }; -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ class LocalThing { -+ y = "ok" -+ } -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js index 5655e386f5..3b8a96a2fd 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js @@ -152,3 +152,68 @@ export = _default; declare class LocalThing { y: string; } + + +//// [DtsFileErrors] + + +out/mixed.d.ts(19,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== out/index.d.ts (0 errors) ==== + export {}; + export type PropName = string | number | symbol; + export type NumberToStringCb = (a: number) => string; + export type MixinName = T & { + name: string; + }; + export type Identity = (x: T) => T; + /** + * @typedef {string | number | symbol} PropName + */ + /** + * Callback + * + * @callback NumberToStringCb + * @param {number} a + * @returns {string} + */ + /** + * @template T + * @typedef {T & {name: string}} MixinName + */ + /** + * Identity function + * + * @template T + * @callback Identity + * @param {T} x + * @returns {T} + */ + +==== out/mixed.d.ts (1 errors) ==== + export type SomeType = { + x: string; + } | number | LocalThing | ExportedThing; + /** + * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType + */ + /** + * @param {number} x + * @returns {SomeType} + */ + declare function doTheThing(x: number): SomeType; + declare class ExportedThing { + z: string; + } + declare const _default: { + doTheThing: typeof doTheThing; + ExportedThing: typeof ExportedThing; + }; + export = _default; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + declare class LocalThing { + y: string; + } + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js.diff index e04dd665c3..436a6c6dc2 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js.diff @@ -78,4 +78,69 @@ declare class LocalThing { y: string; } --export {}; \ No newline at end of file +-export {}; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/mixed.d.ts(19,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++ ++ ++==== out/index.d.ts (0 errors) ==== ++ export {}; ++ export type PropName = string | number | symbol; ++ export type NumberToStringCb = (a: number) => string; ++ export type MixinName = T & { ++ name: string; ++ }; ++ export type Identity = (x: T) => T; ++ /** ++ * @typedef {string | number | symbol} PropName ++ */ ++ /** ++ * Callback ++ * ++ * @callback NumberToStringCb ++ * @param {number} a ++ * @returns {string} ++ */ ++ /** ++ * @template T ++ * @typedef {T & {name: string}} MixinName ++ */ ++ /** ++ * Identity function ++ * ++ * @template T ++ * @callback Identity ++ * @param {T} x ++ * @returns {T} ++ */ ++ ++==== out/mixed.d.ts (1 errors) ==== ++ export type SomeType = { ++ x: string; ++ } | number | LocalThing | ExportedThing; ++ /** ++ * @typedef {{x: string} | number | LocalThing | ExportedThing} SomeType ++ */ ++ /** ++ * @param {number} x ++ * @returns {SomeType} ++ */ ++ declare function doTheThing(x: number): SomeType; ++ declare class ExportedThing { ++ z: string; ++ } ++ declare const _default: { ++ doTheThing: typeof doTheThing; ++ ExportedThing: typeof ExportedThing; ++ }; ++ export = _default; ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ++ declare class LocalThing { ++ y: string; ++ } ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt deleted file mode 100644 index 23837dfb7d..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt +++ /dev/null @@ -1,46 +0,0 @@ -conn.js(11,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -usage.js(11,37): error TS2694: Namespace 'Conn' has no exported member 'Whatever'. -usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== conn.js (1 errors) ==== - /** - * @typedef {string | number} Whatever - */ - - class Conn { - constructor() {} - item = 3; - method() {} - } - - module.exports = Conn; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - -==== usage.js (2 errors) ==== - /** - * @typedef {import("./conn")} Conn - */ - - class Wrap { - /** - * @param {Conn} c - */ - constructor(c) { - this.connItem = c.item; - /** @type {import("./conn").Whatever} */ - ~~~~~~~~ -!!! error TS2694: Namespace 'Conn' has no exported member 'Whatever'. - this.another = ""; - } - } - - module.exports = { - ~~~~~~~~~~~~~~~~~~ - Wrap - ~~~~~~~~ - }; - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff deleted file mode 100644 index 63315a780b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff +++ /dev/null @@ -1,50 +0,0 @@ ---- old.jsDeclarationsTypedefAndImportTypes.errors.txt -+++ new.jsDeclarationsTypedefAndImportTypes.errors.txt -@@= skipped -0, +0 lines =@@ -- -+conn.js(11,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+usage.js(11,37): error TS2694: Namespace 'Conn' has no exported member 'Whatever'. -+usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== conn.js (1 errors) ==== -+ /** -+ * @typedef {string | number} Whatever -+ */ -+ -+ class Conn { -+ constructor() {} -+ item = 3; -+ method() {} -+ } -+ -+ module.exports = Conn; -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+==== usage.js (2 errors) ==== -+ /** -+ * @typedef {import("./conn")} Conn -+ */ -+ -+ class Wrap { -+ /** -+ * @param {Conn} c -+ */ -+ constructor(c) { -+ this.connItem = c.item; -+ /** @type {import("./conn").Whatever} */ -+ ~~~~~~~~ -+!!! error TS2694: Namespace 'Conn' has no exported member 'Whatever'. -+ this.another = ""; -+ } -+ } -+ -+ module.exports = { -+ ~~~~~~~~~~~~~~~~~~ -+ Wrap -+ ~~~~~~~~ -+ }; -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js index d323fab0d8..a410b3a122 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js @@ -84,3 +84,45 @@ declare const _default: { Wrap: typeof Wrap; }; export = _default; + + +//// [DtsFileErrors] + + +out/conn.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +out/conn.d.ts(5,10): error TS2304: Cannot find name 'Conn'. +out/usage.d.ts(4,20): error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? +out/usage.d.ts(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + +==== out/conn.d.ts (2 errors) ==== + /** + * @typedef {string | number} Whatever + */ + export type Whatever = string | number; + export = Conn; + ~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + ~~~~ +!!! error TS2304: Cannot find name 'Conn'. + +==== out/usage.d.ts (2 errors) ==== + /** + * @typedef {import("./conn")} Conn + */ + export type Conn = import("./conn"); + ~~~~~~~~~~~~~~~~ +!!! error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? + declare class Wrap { + /** + * @param {Conn} c + */ + constructor(c: Conn); + } + declare const _default: { + Wrap: typeof Wrap; + }; + export = _default; + ~~~~~~~~~~~~~~~~~~ +!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js.diff index 9a56e87ff8..490a93b422 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js.diff @@ -51,4 +51,46 @@ +declare const _default: { + Wrap: typeof Wrap; +}; -+export = _default; \ No newline at end of file ++export = _default; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/conn.d.ts(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++out/conn.d.ts(5,10): error TS2304: Cannot find name 'Conn'. ++out/usage.d.ts(4,20): error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? ++out/usage.d.ts(14,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++ ++ ++==== out/conn.d.ts (2 errors) ==== ++ /** ++ * @typedef {string | number} Whatever ++ */ ++ export type Whatever = string | number; ++ export = Conn; ++ ~~~~~~~~~~~~~~ ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ++ ~~~~ ++!!! error TS2304: Cannot find name 'Conn'. ++ ++==== out/usage.d.ts (2 errors) ==== ++ /** ++ * @typedef {import("./conn")} Conn ++ */ ++ export type Conn = import("./conn"); ++ ~~~~~~~~~~~~~~~~ ++!!! error TS1340: Module './conn' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./conn')'? ++ declare class Wrap { ++ /** ++ * @param {Conn} c ++ */ ++ constructor(c: Conn); ++ } ++ declare const _default: { ++ Wrap: typeof Wrap; ++ }; ++ export = _default; ++ ~~~~~~~~~~~~~~~~~~ ++!!! error TS2309: An export assignment cannot be used in a module with other exported elements. ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types index 09d2acf0b9..4c33532166 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types @@ -50,9 +50,9 @@ class Wrap { /** @type {import("./conn").Whatever} */ this.another = ""; >this.another = "" : "" ->this.another : any +>this.another : import("conn").Whatever >this : this ->another : any +>another : import("conn").Whatever >"" : "" } } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types.diff index 7a95280823..993f618573 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.types.diff @@ -9,17 +9,7 @@ >exports : typeof Conn >Conn : typeof Conn -@@= skipped -30, +30 lines =@@ - /** @type {import("./conn").Whatever} */ - this.another = ""; - >this.another = "" : "" -->this.another : import("conn").Whatever -+>this.another : any - >this : this -->another : import("conn").Whatever -+>another : any - >"" : "" - } +@@= skipped -38, +38 lines =@@ } module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt deleted file mode 100644 index 4c105d6974..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt +++ /dev/null @@ -1,28 +0,0 @@ -LazySet.js(13,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== index.js (0 errors) ==== - const LazySet = require("./LazySet"); - - /** @type {LazySet} */ - const stringSet = undefined; - stringSet.addAll(stringSet); - - -==== LazySet.js (1 errors) ==== - // Comment out this JSDoc, and note that the errors index.js go away. - /** - * @typedef {Object} SomeObject - */ - class LazySet { - /** - * @param {LazySet} iterable - */ - addAll(iterable) {} - [Symbol.iterator]() {} - } - - module.exports = LazySet; - ~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff deleted file mode 100644 index cbea1dc733..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff +++ /dev/null @@ -1,32 +0,0 @@ ---- old.jsDeclarationsTypedefAndLatebound.errors.txt -+++ new.jsDeclarationsTypedefAndLatebound.errors.txt -@@= skipped -0, +0 lines =@@ -- -+LazySet.js(13,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== index.js (0 errors) ==== -+ const LazySet = require("./LazySet"); -+ -+ /** @type {LazySet} */ -+ const stringSet = undefined; -+ stringSet.addAll(stringSet); -+ -+ -+==== LazySet.js (1 errors) ==== -+ // Comment out this JSDoc, and note that the errors index.js go away. -+ /** -+ * @typedef {Object} SomeObject -+ */ -+ class LazySet { -+ /** -+ * @param {LazySet} iterable -+ */ -+ addAll(iterable) {} -+ [Symbol.iterator]() {} -+ } -+ -+ module.exports = LazySet; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt index 0bb4eb949a..c9b3566f18 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt @@ -1,15 +1,10 @@ -index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. -index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. module.js(24,12): error TS2315: Type 'Object' is not generic. -module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== index.js (2 errors) ==== +==== index.js (0 errors) ==== const {taskGroups, taskNameToGroup} = require('./module.js'); /** @typedef {import('./module.js').TaskGroup} TaskGroup */ - ~~~~~~~~~ -!!! error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. /** * @typedef TaskNode @@ -28,9 +23,7 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w } module.exports = MainThreadTasks; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== module.js (2 errors) ==== +==== module.js (1 errors) ==== /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ /** @@ -60,11 +53,6 @@ module.js(27,1): error TS2309: An export assignment cannot be used in a module w const taskNameToGroup = {}; module.exports = { - ~~~~~~~~~~~~~~~~~~ taskGroups, - ~~~~~~~~~~~~~~~ taskNameToGroup, - ~~~~~~~~~~~~~~~~~~~~ - }; - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file + }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff index a95ad05e93..7225b551de 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff @@ -2,18 +2,13 @@ +++ new.jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt @@= skipped -0, +0 lines =@@ - -+index.js(3,37): error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. -+index.js(21,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +module.js(24,12): error TS2315: Type 'Object' is not generic. -+module.js(27,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== index.js (2 errors) ==== ++==== index.js (0 errors) ==== + const {taskGroups, taskNameToGroup} = require('./module.js'); + + /** @typedef {import('./module.js').TaskGroup} TaskGroup */ -+ ~~~~~~~~~ -+!!! error TS2694: Namespace '"module".export=' has no exported member 'TaskGroup'. + + /** + * @typedef TaskNode @@ -32,9 +27,7 @@ + } + + module.exports = MainThreadTasks; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== module.js (2 errors) ==== ++==== module.js (1 errors) ==== + /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + + /** @@ -64,11 +57,6 @@ + const taskNameToGroup = {}; + + module.exports = { -+ ~~~~~~~~~~~~~~~~~~ + taskGroups, -+ ~~~~~~~~~~~~~~~ + taskNameToGroup, -+ ~~~~~~~~~~~~~~~~~~~~ -+ }; -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file ++ }; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types index 02e415dd5a..f0c4cfcdab 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types @@ -26,7 +26,7 @@ class MainThreadTasks { * @param {TaskNode} y */ constructor(x, y){} ->x : any +>x : import("module").TaskGroup >y : TaskNode } diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff index 811f187d26..9d25d4d5c9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff @@ -11,15 +11,7 @@ >require : any >'./module.js' : "./module.js" -@@= skipped -23, +23 lines =@@ - * @param {TaskNode} y - */ - constructor(x, y){} -->x : import("module").TaskGroup -+>x : any - >y : TaskNode - } - +@@= skipped -30, +30 lines =@@ module.exports = MainThreadTasks; >module.exports = MainThreadTasks : typeof MainThreadTasks >module.exports : typeof MainThreadTasks @@ -28,7 +20,7 @@ >exports : typeof MainThreadTasks >MainThreadTasks : typeof MainThreadTasks -@@= skipped -58, +58 lines =@@ +@@= skipped -51, +51 lines =@@ /** @type {Object} */ const taskNameToGroup = {}; diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt deleted file mode 100644 index d5614f6c67..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt +++ /dev/null @@ -1,37 +0,0 @@ -MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== MC.js (1 errors) ==== - const MW = require("./MW"); - - /** @typedef {number} Cictema */ - - module.exports = class MC { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ - watch() { - ~~~~~~~~~~~ - return new MW(this); - ~~~~~~~~~~~~~~~~~~~~~~~~ - } - ~~~ - }; - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - -==== MW.js (1 errors) ==== - /** @typedef {import("./MC")} MC */ - - class MW { - /** - * @param {MC} compiler the compiler - */ - constructor(compiler) { - this.compiler = compiler; - } - } - - module.exports = MW; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff deleted file mode 100644 index 9e66ced279..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff +++ /dev/null @@ -1,41 +0,0 @@ ---- old.jsdocTypeReferenceToImportOfClassExpression.errors.txt -+++ new.jsdocTypeReferenceToImportOfClassExpression.errors.txt -@@= skipped -0, +0 lines =@@ -- -+MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== MC.js (1 errors) ==== -+ const MW = require("./MW"); -+ -+ /** @typedef {number} Cictema */ -+ -+ module.exports = class MC { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+ watch() { -+ ~~~~~~~~~~~ -+ return new MW(this); -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+ } -+ ~~~ -+ }; -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+==== MW.js (1 errors) ==== -+ /** @typedef {import("./MC")} MC */ -+ -+ class MW { -+ /** -+ * @param {MC} compiler the compiler -+ */ -+ constructor(compiler) { -+ this.compiler = compiler; -+ } -+ } -+ -+ module.exports = MW; -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt index 38ff7cb972..c417b8fb00 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt @@ -1,27 +1,19 @@ -MC.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. MW.js(1,15): error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? -MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MC.js (1 errors) ==== +==== MC.js (0 errors) ==== const MW = require("./MW"); /** @typedef {number} Meyerhauser */ /** @class */ module.exports = function MC() { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** @type {any} */ - ~~~~~~~~~~~~~~~~~~~~~~ var x = {} - ~~~~~~~~~~~~~~ return new MW(x); - ~~~~~~~~~~~~~~~~~~~~~ }; - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== MW.js (2 errors) ==== +==== MW.js (1 errors) ==== /** @typedef {import("./MC")} MC */ ~~~~~~~~~~~~~~ !!! error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? @@ -36,6 +28,4 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with } module.exports = MW; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff index b9969a5cd3..9bfe5f4620 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff @@ -2,30 +2,22 @@ +++ new.jsdocTypeReferenceToImportOfFunctionExpression.errors.txt @@= skipped -0, +0 lines =@@ - -+MC.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +MW.js(1,15): error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? -+MW.js(12,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== MC.js (1 errors) ==== ++==== MC.js (0 errors) ==== + const MW = require("./MW"); + + /** @typedef {number} Meyerhauser */ + + /** @class */ + module.exports = function MC() { -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + /** @type {any} */ -+ ~~~~~~~~~~~~~~~~~~~~~~ + var x = {} -+ ~~~~~~~~~~~~~~ + return new MW(x); -+ ~~~~~~~~~~~~~~~~~~~~~ + }; -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== MW.js (2 errors) ==== ++==== MW.js (1 errors) ==== + /** @typedef {import("./MC")} MC */ + ~~~~~~~~~~~~~~ +!!! error TS1340: Module './MC' does not refer to a type, but is used as a type here. Did you mean 'typeof import('./MC')'? @@ -40,6 +32,4 @@ + } + + module.exports = MW; -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt index 88bbc580cf..7282ad6b89 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt @@ -3,7 +3,6 @@ index.ts(3,24): error TS2694: Namespace '"mod".export=' has no exported member ' index.ts(4,24): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. index.ts(5,24): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. index.ts(6,24): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. -index.ts(7,24): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. index.ts(8,24): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. index.ts(19,31): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. main.js(2,28): error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. @@ -11,36 +10,25 @@ main.js(3,28): error TS2694: Namespace '"mod".export=' has no exported member 'A main.js(4,28): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. main.js(5,28): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. main.js(6,28): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. -main.js(7,28): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. main.js(8,28): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. main.js(20,35): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -mod.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== mod.js (1 errors) ==== +==== mod.js (0 errors) ==== class Thing { x = 1 } class AnotherThing { y = 2 } function foo() { return 3 } function bar() { return 4 } /** @typedef {() => number} buz */ module.exports = { - ~~~~~~~~~~~~~~~~~~ Thing, - ~~~~~~~~~~ AnotherThing, - ~~~~~~~~~~~~~~~~~ foo, - ~~~~~~~~ qux: bar, - ~~~~~~~~~~~~~ baz() { return 5 }, - ~~~~~~~~~~~~~~~~~~~~~~~ literal: "", - ~~~~~~~~~~~~~~~~ } - ~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== main.js (8 errors) ==== +==== main.js (7 errors) ==== /** * @param {import("./mod").Thing} a ~~~~~ @@ -58,8 +46,6 @@ mod.js(6,1): error TS2309: An export assignment cannot be used in a module with ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. * @param {import("./mod").buz} f - ~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {import("./mod").literal} g ~~~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'literal'. @@ -83,7 +69,7 @@ mod.js(6,1): error TS2309: An export assignment cannot be used in a module with return a.length + b.length + c() + d() + e() + f() + g.length } -==== index.ts (8 errors) ==== +==== index.ts (7 errors) ==== function types( a: import('./mod').Thing, ~~~~~ @@ -101,8 +87,6 @@ mod.js(6,1): error TS2309: An export assignment cannot be used in a module with ~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. f: import('./mod').buz, - ~~~ -!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. g: import('./mod').literal, ~~~~~~~ !!! error TS2694: Namespace '"mod".export=' has no exported member 'literal'. diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt.diff index db60a68388..d14e966a91 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.errors.txt.diff @@ -1,10 +1,7 @@ --- old.moduleExportAssignment7.errors.txt +++ new.moduleExportAssignment7.errors.txt -@@= skipped -2, +2 lines =@@ - index.ts(4,24): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. - index.ts(5,24): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. +@@= skipped -4, +4 lines =@@ index.ts(6,24): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. -+index.ts(7,24): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. index.ts(8,24): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. index.ts(19,31): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. +main.js(2,28): error TS2694: Namespace '"mod".export=' has no exported member 'Thing'. @@ -12,40 +9,16 @@ +main.js(4,28): error TS2694: Namespace '"mod".export=' has no exported member 'foo'. +main.js(5,28): error TS2694: Namespace '"mod".export=' has no exported member 'qux'. +main.js(6,28): error TS2694: Namespace '"mod".export=' has no exported member 'baz'. -+main.js(7,28): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. +main.js(8,28): error TS2694: Namespace '"mod".export=' has no exported member 'literal'. main.js(20,35): error TS2694: Namespace '"mod".export=' has no exported member 'buz'. -- -- --==== mod.js (0 errors) ==== -+mod.js(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== mod.js (1 errors) ==== - class Thing { x = 1 } - class AnotherThing { y = 2 } - function foo() { return 3 } - function bar() { return 4 } - /** @typedef {() => number} buz */ - module.exports = { -+ ~~~~~~~~~~~~~~~~~~ - Thing, -+ ~~~~~~~~~~ - AnotherThing, -+ ~~~~~~~~~~~~~~~~~ - foo, -+ ~~~~~~~~ - qux: bar, -+ ~~~~~~~~~~~~~ + + +@@= skipped -17, +23 lines =@@ baz() { return 5 }, -+ ~~~~~~~~~~~~~~~~~~~~~~~ literal: "", -+ ~~~~~~~~~~~~~~~~ } -==== main.js (1 errors) ==== -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== main.js (8 errors) ==== ++==== main.js (7 errors) ==== /** * @param {import("./mod").Thing} a + ~~~~~ @@ -63,29 +36,9 @@ + ~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. * @param {import("./mod").buz} f -+ ~~~ -+!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. * @param {import("./mod").literal} g + ~~~~~~~ +!!! error TS2694: Namespace '"mod".export=' has no exported member 'literal'. */ function jstypes(a, b, c, d, e, f, g) { - return a.x + b.y + c() + d() + e() + f() + g.length -@@= skipped -48, +80 lines =@@ - return a.length + b.length + c() + d() + e() + f() + g.length - } - --==== index.ts (7 errors) ==== -+==== index.ts (8 errors) ==== - function types( - a: import('./mod').Thing, - ~~~~~ -@@= skipped -18, +18 lines =@@ - ~~~ - !!! error TS2694: Namespace '"mod".export=' has no exported member 'baz'. - f: import('./mod').buz, -+ ~~~ -+!!! error TS2694: Namespace '"mod".export=' has no exported member 'buz'. - g: import('./mod').literal, - ~~~~~~~ - !!! error TS2694: Namespace '"mod".export=' has no exported member 'literal'. \ No newline at end of file + return a.x + b.y + c() + d() + e() + f() + g.length \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols index 02c9e60dff..09a4648b00 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols @@ -126,6 +126,7 @@ function types( f: import('./mod').buz, >f : Symbol(f, Decl(index.ts, 5, 27)) +>buz : Symbol(buz, Decl(mod.js, 4, 4)) g: import('./mod').literal, >g : Symbol(g, Decl(index.ts, 6, 27)) diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff index 63cbc827a3..c7c17fd8a9 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff @@ -30,12 +30,4 @@ ->length : Symbol(String.length, Decl(lib.es5.d.ts, --, --)) } - /** -@@= skipped -71, +65 lines =@@ - - f: import('./mod').buz, - >f : Symbol(f, Decl(index.ts, 5, 27)) -->buz : Symbol(buz, Decl(mod.js, 4, 4)) - - g: import('./mod').literal, - >g : Symbol(g, Decl(index.ts, 6, 27)) \ No newline at end of file + /** \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types index 666bc82208..6d017dd7c6 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types @@ -59,13 +59,13 @@ module.exports = { * @param {import("./mod").literal} g */ function jstypes(a, b, c, d, e, f, g) { ->jstypes : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any +>jstypes : (a: any, b: any, c: any, d: any, e: any, f: import("mod").buz, g: any) => any >a : any >b : any >c : any >d : any >e : any ->f : any +>f : import("mod").buz >g : any return a.x + b.y + c() + d() + e() + f() + g.length @@ -87,8 +87,8 @@ function jstypes(a, b, c, d, e, f, g) { >d : any >e() : any >e : any ->f() : any ->f : any +>f() : number +>f : import("mod").buz >g.length : any >g : any >length : any @@ -141,7 +141,7 @@ function jsvalues(a, b, c, d, e, f, g) { === index.ts === function types( ->types : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any +>types : (a: any, b: any, c: any, d: any, e: any, f: import("mod").buz, g: any) => any a: import('./mod').Thing, >a : any @@ -159,7 +159,7 @@ function types( >e : any f: import('./mod').buz, ->f : any +>f : import("mod").buz g: import('./mod').literal, >g : any @@ -184,8 +184,8 @@ function types( >d : any >e() : any >e : any ->f() : any ->f : any +>f() : number +>f : import("mod").buz >g.length : any >g : any >length : any diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types.diff b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types.diff index 8f88508c7d..e856782178 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types.diff @@ -19,15 +19,14 @@ ->c : () => number ->d : () => number ->e : () => number -->f : import("mod").buz -->g : string -+>jstypes : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any ++>jstypes : (a: any, b: any, c: any, d: any, e: any, f: import("mod").buz, g: any) => any +>a : any +>b : any +>c : any +>d : any +>e : any -+>f : any + >f : import("mod").buz +->g : string +>g : any return a.x + b.y + c() + d() + e() + f() + g.length @@ -49,11 +48,6 @@ ->d : () => number ->e() : number ->e : () => number -->f() : number -->f : import("mod").buz -->g.length : number -->g : string -->length : number +>a.x + b.y + c() + d() + e() + f() + g.length : any +>a.x + b.y + c() + d() + e() + f() : any +>a.x + b.y + c() + d() + e() : any @@ -72,8 +66,11 @@ +>d : any +>e() : any +>e : any -+>f() : any -+>f : any + >f() : number + >f : import("mod").buz +->g.length : number +->g : string +->length : number +>g.length : any +>g : any +>length : any @@ -94,30 +91,11 @@ === index.ts === function types( ->types : (a: import("./mod").Thing, b: import("./mod").AnotherThing, c: import("./mod").foo, d: import("./mod").qux, e: import("./mod").baz, f: import("./mod").buz, g: import("./mod").literal) => any -+>types : (a: any, b: any, c: any, d: any, e: any, f: any, g: any) => any ++>types : (a: any, b: any, c: any, d: any, e: any, f: import("mod").buz, g: any) => any a: import('./mod').Thing, >a : any -@@= skipped -18, +18 lines =@@ - >e : any - - f: import('./mod').buz, -->f : import("mod").buz -+>f : any - - g: import('./mod').literal, - >g : any -@@= skipped -25, +25 lines =@@ - >d : any - >e() : any - >e : any -->f() : number -->f : import("mod").buz -+>f() : any -+>f : any - >g.length : any - >g : any - >length : any +@@= skipped -51, +51 lines =@@ } function values( diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt deleted file mode 100644 index cec769759b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt +++ /dev/null @@ -1,50 +0,0 @@ -mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -use.js(1,29): error TS2694: Namespace 'C' has no exported member 'Both'. - - -==== commonjs.d.ts (0 errors) ==== - declare var module: { exports: any}; -==== mod1.js (1 errors) ==== - /// - /** @typedef {{ type: "a", x: 1 }} A */ - /** @typedef {{ type: "b", y: 1 }} B */ - /** @typedef {A | B} Both */ - module.exports = C - ~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - function C() { - this.p = 1 - } - -==== mod2.js (0 errors) ==== - /// - /** @typedef {{ type: "a", x: 1 }} A */ - /** @typedef {{ type: "b", y: 1 }} B */ - /** @typedef {A | B} Both */ - - export function C() { - this.p = 1 - } - -==== mod3.js (0 errors) ==== - /// - /** @typedef {{ type: "a", x: 1 }} A */ - /** @typedef {{ type: "b", y: 1 }} B */ - /** @typedef {A | B} Both */ - - exports.C = function() { - this.p = 1 - } - -==== use.js (1 errors) ==== - /** @type {import('./mod1').Both} */ - ~~~~ -!!! error TS2694: Namespace 'C' has no exported member 'Both'. - var both1 = { type: 'a', x: 1 }; - /** @type {import('./mod2').Both} */ - var both2 = both1; - /** @type {import('./mod3').Both} */ - var both3 = both2; - - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt.diff deleted file mode 100644 index 09af25bcff..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt.diff +++ /dev/null @@ -1,54 +0,0 @@ ---- old.typedefCrossModule.errors.txt -+++ new.typedefCrossModule.errors.txt -@@= skipped -0, +0 lines =@@ -- -+mod1.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+use.js(1,29): error TS2694: Namespace 'C' has no exported member 'Both'. -+ -+ -+==== commonjs.d.ts (0 errors) ==== -+ declare var module: { exports: any}; -+==== mod1.js (1 errors) ==== -+ /// -+ /** @typedef {{ type: "a", x: 1 }} A */ -+ /** @typedef {{ type: "b", y: 1 }} B */ -+ /** @typedef {A | B} Both */ -+ module.exports = C -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+ function C() { -+ this.p = 1 -+ } -+ -+==== mod2.js (0 errors) ==== -+ /// -+ /** @typedef {{ type: "a", x: 1 }} A */ -+ /** @typedef {{ type: "b", y: 1 }} B */ -+ /** @typedef {A | B} Both */ -+ -+ export function C() { -+ this.p = 1 -+ } -+ -+==== mod3.js (0 errors) ==== -+ /// -+ /** @typedef {{ type: "a", x: 1 }} A */ -+ /** @typedef {{ type: "b", y: 1 }} B */ -+ /** @typedef {A | B} Both */ -+ -+ exports.C = function() { -+ this.p = 1 -+ } -+ -+==== use.js (1 errors) ==== -+ /** @type {import('./mod1').Both} */ -+ ~~~~ -+!!! error TS2694: Namespace 'C' has no exported member 'Both'. -+ var both1 = { type: 'a', x: 1 }; -+ /** @type {import('./mod2').Both} */ -+ var both2 = both1; -+ /** @type {import('./mod3').Both} */ -+ var both3 = both2; -+ -+ -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types index 2df8da37ca..8c1620c507 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types @@ -69,22 +69,22 @@ exports.C = function() { === use.js === /** @type {import('./mod1').Both} */ var both1 = { type: 'a', x: 1 }; ->both1 : any ->{ type: 'a', x: 1 } : { type: string; x: number; } ->type : string +>both1 : import("mod1").Both +>{ type: 'a', x: 1 } : { type: "a"; x: 1; } +>type : "a" >'a' : "a" ->x : number +>x : 1 >1 : 1 /** @type {import('./mod2').Both} */ var both2 = both1; >both2 : import("mod2").Both ->both1 : any +>both1 : import("mod1").A /** @type {import('./mod3').Both} */ var both3 = both2; >both3 : import("mod3").Both ->both2 : import("mod2").Both +>both2 : import("mod2").A diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types.diff index a35eb7c1b9..d4e725b6e8 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types.diff @@ -63,32 +63,4 @@ +>this : any >p : any >1 : 1 - } -@@= skipped -17, +17 lines =@@ - === use.js === - /** @type {import('./mod1').Both} */ - var both1 = { type: 'a', x: 1 }; -->both1 : import("mod1").Both -->{ type: 'a', x: 1 } : { type: "a"; x: 1; } -->type : "a" -+>both1 : any -+>{ type: 'a', x: 1 } : { type: string; x: number; } -+>type : string - >'a' : "a" -->x : 1 -+>x : number - >1 : 1 - - /** @type {import('./mod2').Both} */ - var both2 = both1; - >both2 : import("mod2").Both -->both1 : import("mod1").A -+>both1 : any - - /** @type {import('./mod3').Both} */ - var both3 = both2; - >both3 : import("mod3").Both -->both2 : import("mod2").A -+>both2 : import("mod2").Both - - + } \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt index 88c64603d4..b5932b5ecc 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt @@ -1,18 +1,13 @@ -mod1.js(7,9): error TS2339: Property 'Bar' does not exist on type 'typeof import("mod1")'. mod1.js(10,1): error TS2300: Duplicate identifier 'export='. mod1.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. mod1.js(23,1): error TS2741: Property 'Baz' is missing in type '{ Quack: number; }' but required in type '{ Baz: typeof Baz; }'. mod1.js(23,1): error TS2300: Duplicate identifier 'export='. -use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. use.js(4,12): error TS2503: Cannot find namespace 'mod'. -==== use.js (2 errors) ==== +==== use.js (1 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ - ~~~ -!!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ ~~~ @@ -20,7 +15,7 @@ use.js(4,12): error TS2503: Cannot find namespace 'mod'. var bb; var bbb = new mod.Baz(); -==== mod1.js (6 errors) ==== +==== mod1.js (4 errors) ==== // error /** @typedef {number} Foo */ @@ -28,8 +23,6 @@ use.js(4,12): error TS2503: Cannot find namespace 'mod'. /** @typedef {number} Bar */ exports.Bar = class { } - ~~~ -!!! error TS2339: Property 'Bar' does not exist on type 'typeof import("mod1")'. /** @typedef {number} Baz */ module.exports = { @@ -51,8 +44,6 @@ use.js(4,12): error TS2503: Cannot find namespace 'mod'. /** @typedef {number} Quid */ exports.Quid = 2; - ~~~~ -!!! error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. /** @typedef {number} Quack */ module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff index 42d0aaf0bd..61cd60d210 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt.diff @@ -8,21 +8,16 @@ - - -==== use.js (0 errors) ==== -+mod1.js(7,9): error TS2339: Property 'Bar' does not exist on type 'typeof import("mod1")'. +mod1.js(10,1): error TS2300: Duplicate identifier 'export='. +mod1.js(10,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+mod1.js(20,9): error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. +mod1.js(23,1): error TS2741: Property 'Baz' is missing in type '{ Quack: number; }' but required in type '{ Baz: typeof Baz; }'. +mod1.js(23,1): error TS2300: Duplicate identifier 'export='. -+use.js(2,32): error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. +use.js(4,12): error TS2503: Cannot find namespace 'mod'. + + -+==== use.js (2 errors) ==== ++==== use.js (1 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ -+ ~~~ -+!!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ + ~~~ @@ -30,8 +25,7 @@ var bb; var bbb = new mod.Baz(); --==== mod1.js (4 errors) ==== -+==== mod1.js (6 errors) ==== +@@= skipped -15, +18 lines =@@ // error /** @typedef {number} Foo */ @@ -43,8 +37,6 @@ /** @typedef {number} Bar */ exports.Bar = class { } -+ ~~~ -+!!! error TS2339: Property 'Bar' does not exist on type 'typeof import("mod1")'. /** @typedef {number} Baz */ - ~~~ @@ -67,12 +59,7 @@ // ok -@@= skipped -42, +50 lines =@@ - - /** @typedef {number} Quid */ - exports.Quid = 2; -+ ~~~~ -+!!! error TS2339: Property 'Quid' does not exist on type 'typeof import("mod1")'. +@@= skipped -30, +28 lines =@@ /** @typedef {number} Quack */ module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols index 9d110aa536..867c83ab10 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols @@ -29,7 +29,9 @@ class Foo { } // should error /** @typedef {number} Bar */ exports.Bar = class { } +>exports.Bar : Symbol(Bar, Decl(mod1.js, 5, 4), Decl(mod1.js, 3, 13)) >exports : Symbol("mod1", Decl(mod1.js, 0, 0)) +>Bar : Symbol(Bar, Decl(mod1.js, 5, 4), Decl(mod1.js, 3, 13)) /** @typedef {number} Baz */ module.exports = { @@ -49,7 +51,9 @@ var Qux = 2; /** @typedef {number} Quid */ exports.Quid = 2; +>exports.Quid : Symbol(Quid, Decl(mod1.js, 18, 4), Decl(mod1.js, 16, 12)) >exports : Symbol("mod1", Decl(mod1.js, 0, 0)) +>Quid : Symbol(Quid, Decl(mod1.js, 18, 4), Decl(mod1.js, 16, 12)) /** @typedef {number} Quack */ module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff index 056aa427ec..5dc7be7ed0 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff @@ -23,7 +23,9 @@ ->exports.Bar : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) ->exports : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) ->Bar : Symbol(Bar, Decl(mod1.js, 3, 13), Decl(mod1.js, 5, 4)) ++>exports.Bar : Symbol(Bar, Decl(mod1.js, 5, 4), Decl(mod1.js, 3, 13)) +>exports : Symbol("mod1", Decl(mod1.js, 0, 0)) ++>Bar : Symbol(Bar, Decl(mod1.js, 5, 4), Decl(mod1.js, 3, 13)) /** @typedef {number} Baz */ module.exports = { @@ -36,7 +38,7 @@ Baz: class { } >Baz : Symbol(Baz, Decl(mod1.js, 9, 18)) -@@= skipped -31, +29 lines =@@ +@@= skipped -31, +31 lines =@@ /** @typedef {number} Qux */ var Qux = 2; @@ -48,7 +50,9 @@ ->exports.Quid : Symbol(Quid, Decl(mod1.js, 16, 12), Decl(mod1.js, 18, 4)) ->exports : Symbol(Quid, Decl(mod1.js, 16, 12), Decl(mod1.js, 18, 4)) ->Quid : Symbol(Quid, Decl(mod1.js, 16, 12), Decl(mod1.js, 18, 4)) ++>exports.Quid : Symbol(Quid, Decl(mod1.js, 18, 4), Decl(mod1.js, 16, 12)) +>exports : Symbol("mod1", Decl(mod1.js, 0, 0)) ++>Quid : Symbol(Quid, Decl(mod1.js, 18, 4), Decl(mod1.js, 16, 12)) /** @typedef {number} Quack */ module.exports = { diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types index 9318e46cff..e5f7b574f8 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types @@ -9,7 +9,7 @@ var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ var b; ->b : any +>b : number /** @type {mod.Baz} */ var bb; @@ -32,9 +32,9 @@ class Foo { } // should error /** @typedef {number} Bar */ exports.Bar = class { } >exports.Bar = class { } : typeof Bar ->exports.Bar : any +>exports.Bar : typeof Bar >exports : typeof import("mod1") ->Bar : any +>Bar : typeof Bar >class { } : typeof Bar /** @typedef {number} Baz */ @@ -60,9 +60,9 @@ var Qux = 2; /** @typedef {number} Quid */ exports.Quid = 2; >exports.Quid = 2 : 2 ->exports.Quid : any +>exports.Quid : 2 >exports : typeof import("mod1") ->Quid : any +>Quid : 2 >2 : 2 /** @typedef {number} Quack */ diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types.diff index 177416b72c..4b5565b779 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types.diff @@ -11,10 +11,7 @@ >require : any >'./mod1.js' : "./mod1.js" - /** @type {import("./mod1.js").Baz} */ - var b; -->b : number -+>b : any +@@= skipped -11, +11 lines =@@ /** @type {mod.Baz} */ var bb; @@ -30,16 +27,13 @@ >Baz : typeof Baz === mod1.js === -@@= skipped -30, +30 lines =@@ - /** @typedef {number} Bar */ +@@= skipped -20, +20 lines =@@ exports.Bar = class { } >exports.Bar = class { } : typeof Bar -->exports.Bar : typeof Bar + >exports.Bar : typeof Bar ->exports : { Bar: typeof Bar; Baz: typeof Baz; Quid: 2; Quack?: undefined; } | { Bar: typeof Bar; Baz?: undefined; Quid: 2; Quack: number; } -->Bar : typeof Bar -+>exports.Bar : any +>exports : typeof import("mod1") -+>Bar : any + >Bar : typeof Bar >class { } : typeof Bar /** @typedef {number} Baz */ @@ -56,15 +50,12 @@ Baz: class { } @@= skipped -28, +28 lines =@@ - /** @typedef {number} Quid */ exports.Quid = 2; >exports.Quid = 2 : 2 -->exports.Quid : 2 + >exports.Quid : 2 ->exports : { Bar: typeof Bar; Baz: typeof Baz; Quid: 2; Quack?: undefined; } | { Bar: typeof Bar; Baz?: undefined; Quid: 2; Quack: number; } -->Quid : 2 -+>exports.Quid : any +>exports : typeof import("mod1") -+>Quid : any + >Quid : 2 >2 : 2 /** @typedef {number} Quack */ diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt deleted file mode 100644 index cb8b1e13b1..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -mod2.js(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== mod2.js (1 errors) ==== - /** @typedef {number} Foo */ - const ns = {}; - ns.Foo = class {} - module.exports = ns; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt.diff index 36296f2c15..ae9af08179 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt.diff @@ -6,21 +6,16 @@ - - -==== mod2.js (2 errors) ==== -+mod2.js(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== mod2.js (1 errors) ==== - /** @typedef {number} Foo */ +- /** @typedef {number} Foo */ - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -!!! related TS6203 mod2.js:3:4: 'Foo' was also declared here. - const ns = {}; - ns.Foo = class {} +- const ns = {}; +- ns.Foo = class {} - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -!!! related TS6203 mod2.js:1:23: 'Foo' was also declared here. - module.exports = ns; -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - - \ No newline at end of file +- module.exports = ns; +- +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule4.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule4.errors.txt deleted file mode 100644 index a7d9cbb9a3..0000000000 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule4.errors.txt +++ /dev/null @@ -1,11 +0,0 @@ -mod3.js(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== mod3.js (1 errors) ==== - /** @typedef {number} Foo */ - class Bar { } - module.exports = { Foo: Bar }; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule4.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule4.errors.txt.diff index d4e73b5e61..063060311b 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule4.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule4.errors.txt.diff @@ -6,20 +6,15 @@ - - -==== mod3.js (2 errors) ==== -+mod3.js(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== mod3.js (1 errors) ==== - /** @typedef {number} Foo */ +- /** @typedef {number} Foo */ - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -!!! related TS6203 mod3.js:3:20: 'Foo' was also declared here. - class Bar { } - module.exports = { Foo: Bar }; +- class Bar { } +- module.exports = { Foo: Bar }; - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. -!!! related TS6203 mod3.js:1:23: 'Foo' was also declared here. -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. - - \ No newline at end of file +- +- ++ \ No newline at end of file diff --git a/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js b/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js index ecb6d688aa..bbd565a6cd 100644 --- a/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js +++ b/testdata/baselines/reference/tsbuild/javascriptProjectEmit/loads-js-based-projects-and-emits-them-correctly.js @@ -106,11 +106,6 @@ import { Nominal } from '../common/nominal'; tsgo --b ExitStatus:: DiagnosticsPresent_OutputsGenerated Output:: -common/nominal.js:5:1 - error TS2309: An export assignment cannot be used in a module with other exported elements. - -5 module.exports = {}; -  ~~~~~~~~~~~~~~~~~~~ - sub-project/index.js:1:10 - error TS2305: Module '"../../lib/common/nominal"' has no exported member 'Nominal'. 1 import { Nominal } from '../common/nominal'; @@ -122,10 +117,9 @@ Output::    ~~~~~~~~~ -Found 3 errors in 3 files. +Found 2 errors in 2 files. Errors Files - 1 common/nominal.js:5 1 sub-project-2/index.js:1 1 sub-project/index.js:1 @@ -144,7 +138,7 @@ export = _default; module.exports = {}; //// [/home/src/workspaces/lib/common/tsconfig.tsbuildinfo] *new* -{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../../solution/common/nominal.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19075dfba5b2d593b761ed8d8cd526f-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};","signature":"de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n","impliedNodeFormat":1}],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"semanticDiagnosticsPerFile":[[2,[{"pos":80,"end":99,"code":2309,"category":1,"message":"An export assignment cannot be used in a module with other exported elements."}]]],"latestChangedDtsFile":"./nominal.d.ts"} +{"version":"FakeTSVersion","root":[2],"fileNames":["lib.d.ts","../../solution/common/nominal.js"],"fileInfos":[{"version":"24b4796cd50d1a9aabad1583878c494d-/// \ninterface Boolean {}\ninterface Function {}\ninterface CallableFunction {}\ninterface NewableFunction {}\ninterface IArguments {}\ninterface Number { toExponential: any; }\ninterface Object {}\ninterface RegExp {}\ninterface String { charAt: any; }\ninterface Array { length: number; [n: number]: T; }\ninterface ReadonlyArray {}\ninterface SymbolConstructor {\n readonly species: symbol;\n (desc?: string | number): symbol;\n for(name: string): symbol;\n readonly toStringTag: symbol;\n}\ndeclare var Symbol: SymbolConstructor;\ninterface Symbol {\n readonly [Symbol.toStringTag]: string;\n}\ndeclare const console: { log(msg: any): void; };","affectsGlobalScope":true,"impliedNodeFormat":1},{"version":"a19075dfba5b2d593b761ed8d8cd526f-/**\n * @template T, Name\n * @typedef {T & {[Symbol.species]: Name}} Nominal\n */\nmodule.exports = {};","signature":"de751e2539eb6f12413f7067ad0a0ef5-export type Nominal = T & {\n [Symbol.species]: Name;\n};\ndeclare const _default: {};\nexport = _default;\n","impliedNodeFormat":1}],"options":{"allowJs":true,"checkJs":true,"composite":true,"declaration":true,"outDir":"..","rootDir":"../../solution","skipLibCheck":true},"latestChangedDtsFile":"./nominal.d.ts"} //// [/home/src/workspaces/lib/common/tsconfig.tsbuildinfo.readable.baseline.txt] *new* { "version": "FakeTSVersion", @@ -194,22 +188,8 @@ module.exports = {}; "rootDir": "../../solution", "skipLibCheck": true }, - "semanticDiagnosticsPerFile": [ - [ - "../../solution/common/nominal.js", - [ - { - "pos": 80, - "end": 99, - "code": 2309, - "category": 1, - "message": "An export assignment cannot be used in a module with other exported elements." - } - ] - ] - ], "latestChangedDtsFile": "./nominal.d.ts", - "size": 1606 + "size": 1434 } //// [/home/src/workspaces/lib/sub-project-2/index.d.ts] *new* declare const variable: { diff --git a/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts b/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts new file mode 100644 index 0000000000..3dc1a2e473 --- /dev/null +++ b/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect1.ts @@ -0,0 +1,12 @@ +// @filename: typedefModuleExportsIndirect1.js +// @checkJs: true +// @strict: true +// @outdir: dist +// @declaration: true +/** @typedef {{ a: 1, m: 1 }} C */ +const dummy = 0; +module.exports = dummy; +// @filename: use.js +/** @typedef {import('./typedefModuleExportsIndirect1').C} C */ +/** @type {C} */ +var c diff --git a/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts b/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts new file mode 100644 index 0000000000..bdda577879 --- /dev/null +++ b/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect2.ts @@ -0,0 +1,12 @@ +// @filename: typedefModuleExportsIndirect2.js +// @checkJs: true +// @strict: true +// @outdir: dist +// @declaration: true +/** @typedef {{ a: 1, m: 1 }} C */ +const f = function() {}; +module.exports = f; +// @filename: use.js +/** @typedef {import('./typedefModuleExportsIndirect2').C} C */ +/** @type {C} */ +var c diff --git a/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts b/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts new file mode 100644 index 0000000000..84c8b5736a --- /dev/null +++ b/testdata/tests/cases/conformance/salsa/typedefModuleExportsIndirect3.ts @@ -0,0 +1,12 @@ +// @filename: typedefModuleExportsIndirect3.js +// @checkJs: true +// @strict: true +// @outdir: dist +// @declaration: true +/** @typedef {{ a: 1, m: 1 }} C */ +const o = {}; +module.exports = o; +// @filename: use.js +/** @typedef {import('./typedefModuleExportsIndirect3').C} C */ +/** @type {C} */ +var c