diff --git a/internal/binder/binder.go b/internal/binder/binder.go index f37f203fe3..07c5741197 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -72,6 +72,7 @@ type Binder struct { flowNodePool core.Pool[ast.FlowNode] flowListPool core.Pool[ast.FlowList] singleDeclarationsPool core.Pool[*ast.Node] + delayedTypeAliases []*ast.Node } func (b *Binder) options() core.SourceFileAffectingCompilerOptions { @@ -125,9 +126,32 @@ func bindSourceFile(file *ast.SourceFile) { b.bind(file.AsNode()) file.SymbolCount = b.symbolCount file.ClassifiableNames = b.classifiableNames + b.delayedBindJSDocTypedefTag() }) } +// top-level typedef binding is delayed because it changes based on whether `module.exports = x` is bound +func (b *Binder) delayedBindJSDocTypedefTag() { + if b.delayedTypeAliases == nil { + return + } + if b.file.Symbol != nil { + if exportEq := b.file.Symbol.Exports[ast.InternalSymbolNameExportEquals]; exportEq != nil && b.file.CommonJSModuleIndicator != nil { + for _, node := range b.delayedTypeAliases { + b.declareSymbol(ast.GetSymbolTable(&exportEq.Exports), exportEq /*parent*/, node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes) + b.declareSymbol(ast.GetLocals(b.file.AsNode()), b.file.Symbol, node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes) + } + return + } + } + // bind normally + b.container = b.file.AsNode() + b.blockScopeContainer = b.file.AsNode() + for _, node := range b.delayedTypeAliases { + b.bindBlockScopedDeclaration(node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes) + } +} + func (b *Binder) newSymbol(flags ast.SymbolFlags, name string) *ast.Symbol { b.symbolCount++ result := b.symbolPool.New() @@ -687,8 +711,14 @@ func (b *Binder) bind(node *ast.Node) bool { b.bindBlockScopedDeclaration(node, ast.SymbolFlagsInterface, ast.SymbolFlagsInterfaceExcludes) case ast.KindCallExpression: b.bindCallExpression(node) - case ast.KindTypeAliasDeclaration, ast.KindJSTypeAliasDeclaration: + case ast.KindTypeAliasDeclaration: b.bindBlockScopedDeclaration(node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes) + case ast.KindJSTypeAliasDeclaration: + if b.file.AsNode() == b.container { + b.delayedTypeAliases = append(b.delayedTypeAliases, node) + } else { + b.bindBlockScopedDeclaration(node, ast.SymbolFlagsTypeAlias, ast.SymbolFlagsTypeAliasExcludes) + } case ast.KindEnumDeclaration: b.bindEnumDeclaration(node) case ast.KindModuleDeclaration: diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 75b2f72d53..577627b0e9 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -13788,7 +13788,7 @@ func (c *Checker) getTargetOfImportEqualsDeclaration(node *ast.Node, dontResolve moduleReference = ast.GetExternalModuleImportEqualsDeclarationExpression(node) } immediate := c.resolveExternalModuleName(node, moduleReference, false /*ignoreErrors*/) - resolved := c.resolveExternalModuleSymbol(immediate, false /*dontResolveAlias*/) + resolved := c.resolveExternalModuleSymbol(immediate, dontResolveAlias) c.markSymbolOfAliasDeclarationIfTypeOnly(node, immediate, resolved, false /*overwriteEmpty*/, nil, "") return resolved } @@ -15061,9 +15061,24 @@ func (c *Checker) resolveEntityName(name *ast.Node, meaning ast.SymbolFlags, ign } 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 { - namespace := c.resolveEntityName(left, ast.SymbolFlagsNamespace, ignoreErrors, false /*dontResolveAlias*/, location) + namespace := c.resolveEntityName(left, ast.SymbolFlagsNamespace, true /*ignoreErrors*/, false /*dontResolveAlias*/, location) if namespace == nil || ast.NodeIsMissing(right) { - return nil + var immediate *ast.Symbol + alias := c.resolveEntityName(left, ast.SymbolFlagsAlias, true /*ignoreErrors*/, true /*dontResolveAlias*/, location) + if alias != nil { + immediate = c.getImmediateAliasedSymbol(alias) + if immediate != nil && !core.Some(immediate.Declarations, func(d *ast.Node) bool { return d.Kind == ast.KindJSExportAssignment }) { + immediate = nil + } + } + if immediate == nil { + if !ignoreErrors { + c.resolveEntityName(left, ast.SymbolFlagsNamespace, ignoreErrors, false /*dontResolveAlias*/, location) + } + return nil + } else { + namespace = immediate + } } if namespace == c.unknownSymbol { return namespace @@ -23529,9 +23544,20 @@ func (c *Checker) getTypeFromImportTypeNode(node *ast.Node) *Type { } next := core.OrElse(symbolFromModule, symbolFromVariable) if next == nil { - c.error(current, diagnostics.Namespace_0_has_no_exported_member_1, c.getFullyQualifiedName(currentNamespace, nil), scanner.DeclarationNameToString(current)) - links.resolvedType = c.errorType - return links.resolvedType + var symbolFromImmediateModule *ast.Symbol + if currentNamespace == moduleSymbol { + immediateModuleSymbol := c.resolveExternalModuleSymbol(innerModuleSymbol, true /*dontResolveAlias*/) + if immediateModuleSymbol != nil && core.Some(immediateModuleSymbol.Declarations, func(d *ast.Node) bool { return d.Kind == ast.KindJSExportAssignment }) { + symbolFromImmediateModule = c.getSymbol(c.getExportsOfSymbol(immediateModuleSymbol), current.Text(), meaning) + } + } + if symbolFromImmediateModule != nil { + next = symbolFromImmediateModule + } else { + c.error(current, diagnostics.Namespace_0_has_no_exported_member_1, c.getFullyQualifiedName(currentNamespace, nil), scanner.DeclarationNameToString(current)) + links.resolvedType = c.errorType + return links.resolvedType + } } c.symbolNodeLinks.Get(current).resolvedSymbol = next c.symbolNodeLinks.Get(current.Parent).resolvedSymbol = next diff --git a/internal/parser/reparser.go b/internal/parser/reparser.go index 05148147d7..f030237bf7 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -57,7 +57,6 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) { func (p *Parser) reparseUnhosted(tag *ast.Node, parent *ast.Node, jsDoc *ast.Node) { switch tag.Kind { case ast.KindJSDocTypedefTag: - // !!! Don't mark typedefs as exported if they are not in a module typeExpression := tag.AsJSDocTypedefTag().TypeExpression if typeExpression == nil { break 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/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/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/jsEnumCrossFileExport.errors.txt b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt index 3be4b9a200..3ae916c8ac 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.errors.txt @@ -1,11 +1,10 @@ -enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. index.js(4,17): error TS2503: Cannot find namespace 'Host'. index.js(8,21): error TS2304: Cannot find name 'Host'. index.js(13,11): error TS2503: Cannot find namespace 'Host'. index.js(18,11): error TS2503: Cannot find namespace 'Host'. -==== enumDef.js (1 errors) ==== +==== enumDef.js (0 errors) ==== var Host = {}; Host.UserMetrics = {}; /** @enum {number} */ @@ -22,8 +21,6 @@ index.js(18,11): error TS2503: Cannot find namespace 'Host'. * @typedef {string} */ Host.UserMetrics.Blah = { - ~~~~ -!!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. x: 12 } ==== index.js (4 errors) ==== diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols index 28f88a4f31..cc58e26124 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols @@ -37,9 +37,11 @@ Host.UserMetrics.Action = { * @typedef {string} */ Host.UserMetrics.Blah = { +>Host.UserMetrics.Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) >Host.UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) >Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) >UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) +>Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) x: 12 >x : Symbol(x, Decl(enumDef.js, 15, 25)) diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff index 80901e91ae..eaf7f058e4 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.symbols.diff @@ -39,9 +39,11 @@ ->Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 0, 14), Decl(enumDef.js, 1, 22), Decl(enumDef.js, 8, 2), Decl(enumDef.js, 10, 21)) ->UserMetrics : Symbol(Host.UserMetrics, Decl(enumDef.js, 0, 14), Decl(enumDef.js, 3, 5), Decl(enumDef.js, 15, 5), Decl(enumDef.js, 10, 26)) ->Blah : Symbol(Host.UserMetrics.Blah, Decl(enumDef.js, 8, 2), Decl(enumDef.js, 15, 17), Decl(enumDef.js, 13, 3)) ++>Host.UserMetrics.Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) +>Host.UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) +>Host : Symbol(Host, Decl(enumDef.js, 0, 3), Decl(enumDef.js, 10, 3)) +>UserMetrics : Symbol(UserMetrics, Decl(enumDef.js, 0, 14)) ++>Blah : Symbol(Blah, Decl(enumDef.js, 8, 2)) x: 12 >x : Symbol(x, Decl(enumDef.js, 15, 25)) diff --git a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types index 31d40349d8..589b6736c8 100644 --- a/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types +++ b/testdata/baselines/reference/submodule/compiler/jsEnumCrossFileExport.types @@ -2,23 +2,23 @@ === enumDef.js === var Host = {}; ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } Host.UserMetrics = {}; ->Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } +>Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } /** @enum {number} */ Host.UserMetrics.Action = { >Host.UserMetrics.Action = { WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >Host.UserMetrics.Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } ->Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } +>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } >Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >{ WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } @@ -47,11 +47,11 @@ Host.UserMetrics.Action = { */ Host.UserMetrics.Blah = { >Host.UserMetrics.Blah = { x: 12} : { x: number; } ->Host.UserMetrics.Blah : any ->Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ->UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ->Blah : any +>Host.UserMetrics.Blah : { x: number; } +>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } +>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } +>Blah : { x: number; } >{ x: 12} : { x: number; } x: 12 diff --git a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt b/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt index fd2276e9f7..95ab42f849 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt @@ -1,5 +1,4 @@ typescript-eslint.js(12,17): error TS7019: Rest parameter 'configs' implicitly has an 'any[]' type. -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) ==== @@ -26,7 +25,7 @@ typescript-eslint.js(14,1): error TS2309: An export assignment cannot be used in }, }; -==== typescript-eslint.js (2 errors) ==== +==== typescript-eslint.js (1 errors) ==== /** * @typedef {{ rules: Record }} Plugin */ @@ -43,6 +42,4 @@ typescript-eslint.js(14,1): error TS2309: An export assignment cannot be used in !!! error TS7019: Rest parameter 'configs' implicitly has an 'any[]' type. 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.types b/testdata/baselines/reference/submodule/conformance/callbackCrossModule.types index 675bc5286c..6ba81ad401 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/importingExportingTypes.symbols b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols index e3d5cf7c06..a27e054aaf 100644 --- a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols +++ b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols @@ -28,10 +28,10 @@ import { writeFile, WriteFileOptions, WriteFileOptions as OtherName } from "fs"; /** @typedef {{ x: any }} JSDocType */ export { JSDocType }; ->JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) +>JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8), Decl(index.js, 2, 4)) export { JSDocType as ThisIsFine }; ->JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) +>JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8), Decl(index.js, 2, 4)) >ThisIsFine : Symbol(ThisIsFine, Decl(index.js, 5, 8)) export { WriteFileOptions }; diff --git a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols.diff b/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols.diff deleted file mode 100644 index cac0a7e1fb..0000000000 --- a/testdata/baselines/reference/submodule/conformance/importingExportingTypes.symbols.diff +++ /dev/null @@ -1,15 +0,0 @@ ---- old.importingExportingTypes.symbols -+++ new.importingExportingTypes.symbols -@@= skipped -27, +27 lines =@@ - /** @typedef {{ x: any }} JSDocType */ - - export { JSDocType }; -->JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8), Decl(index.js, 2, 4)) -+>JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) - - export { JSDocType as ThisIsFine }; -->JSDocType : Symbol(JSDocType, Decl(index.js, 4, 8), Decl(index.js, 2, 4)) -+>JSDocType : Symbol(JSDocType, Decl(index.js, 2, 4), Decl(index.js, 4, 8)) - >ThisIsFine : Symbol(ThisIsFine, Decl(index.js, 5, 8)) - - export { WriteFileOptions }; \ 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.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types index fbaba50105..32187d43d8 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/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt index 4fca94994d..d0e41763a9 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@ -4,12 +4,13 @@ file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. +file.js(20,9): 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. -==== file.js (6 errors) ==== +==== file.js (7 errors) ==== /** * @namespace myTypes * @global @@ -42,6 +43,8 @@ file2.js(17,12): error TS2702: 'testFnTypes' only refers to a type, but is being !!! error TS2300: Duplicate identifier 'myTypes'. export {myTypes}; + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. ==== file2.js (3 errors) ==== import {myTypes} from './file.js'; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols index 0c301bfa5c..a5c956f0fb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols @@ -23,7 +23,7 @@ const myTypes = { /** @typedef {myTypes.typeB|Function} myTypes.typeC */ export {myTypes}; ->myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 19, 8)) +>myTypes : Symbol(myTypes, Decl(file.js, 19, 8), Decl(file.js, 9, 4)) === file2.js === import {myTypes} from './file.js'; @@ -65,5 +65,5 @@ function testFn(input) { export {testFn, testFnTypes}; >testFn : Symbol(testFn, Decl(file2.js, 27, 8)) ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 11, 4), Decl(file2.js, 27, 15)) +>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 27, 15), Decl(file2.js, 11, 4)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff index c81e410c7e..10d8b008fa 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.symbols.diff @@ -14,7 +14,7 @@ export {myTypes}; ->myTypes : Symbol(myTypes, Decl(file.js, 19, 8), Decl(file.js, 9, 50), Decl(file.js, 12, 12), Decl(file.js, 17, 38)) -+>myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 19, 8)) ++>myTypes : Symbol(myTypes, Decl(file.js, 19, 8), Decl(file.js, 9, 4)) === file2.js === import {myTypes} from './file.js'; @@ -32,4 +32,4 @@ export {testFn, testFnTypes}; >testFn : Symbol(testFn, Decl(file2.js, 27, 8)) ->testFnTypes : Symbol(testFnTypes, Decl(file2.js, 27, 15), Decl(file2.js, 11, 37)) -+>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 11, 4), Decl(file2.js, 27, 15)) ++>testFnTypes : Symbol(testFnTypes, Decl(file2.js, 27, 15), Decl(file2.js, 11, 4)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt index e25ccebe0d..2007c58d1a 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -4,13 +4,13 @@ file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. +file.js(20,9): 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,9 +45,7 @@ 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) ==== +==== file.js (7 errors) ==== /** * @namespace myTypes * @global @@ -79,4 +77,6 @@ file2.js(28,1): error TS2309: An export assignment cannot be used in a module wi ~~~~~~~ !!! error TS2300: Duplicate identifier 'myTypes'. - exports.myTypes = myTypes; \ No newline at end of file + exports.myTypes = myTypes; + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols index 3882b91669..038f14ac61 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols @@ -70,8 +70,8 @@ const myTypes = { /** @typedef {myTypes.typeB|Function} myTypes.typeC */ exports.myTypes = myTypes; ->exports.myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 7, 2)) +>exports.myTypes : Symbol(myTypes, Decl(file.js, 7, 2), Decl(file.js, 9, 4)) >exports : Symbol("file", Decl(file.js, 0, 0)) ->myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 7, 2)) +>myTypes : Symbol(myTypes, Decl(file.js, 7, 2), Decl(file.js, 9, 4)) >myTypes : Symbol(myTypes, Decl(file.js, 5, 5), Decl(file.js, 9, 4), Decl(file.js, 12, 3), Decl(file.js, 17, 4)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff index a6952ae113..4119083228 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff @@ -39,7 +39,7 @@ ->exports : Symbol(myTypes, Decl(file.js, 7, 2)) ->myTypes : Symbol(myTypes, Decl(file.js, 7, 2)) ->myTypes : Symbol(myTypes, Decl(file.js, 5, 5), Decl(file.js, 9, 50), Decl(file.js, 12, 12), Decl(file.js, 17, 38)) -+>exports.myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 7, 2)) ++>exports.myTypes : Symbol(myTypes, Decl(file.js, 7, 2), Decl(file.js, 9, 4)) +>exports : Symbol("file", Decl(file.js, 0, 0)) -+>myTypes : Symbol(myTypes, Decl(file.js, 9, 4), Decl(file.js, 7, 2)) ++>myTypes : Symbol(myTypes, Decl(file.js, 7, 2), Decl(file.js, 9, 4)) +>myTypes : Symbol(myTypes, Decl(file.js, 5, 5), Decl(file.js, 9, 4), Decl(file.js, 12, 3), Decl(file.js, 17, 4)) diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.errors.txt deleted file mode 100644 index 2368c88fd4..0000000000 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportTypeBundled.errors.txt +++ /dev/null @@ -1,18 +0,0 @@ -folder/mod1.js(8,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - -==== folder/mod1.js (1 errors) ==== - /** - * @typedef {{x: number}} Item - */ - /** - * @type {Item}; - */ - const x = {x: 12}; - module.exports = x; - ~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== index.js (0 errors) ==== - /** @type {(typeof import("./folder/mod1"))[]} */ - const items = [{x: 12}]; - module.exports = items; \ No newline at end of file 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.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js index e7534535c7..2cbe75a8eb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js @@ -148,3 +148,62 @@ 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 {}; // 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} + */ + +==== 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 76e1142926..1a42460630 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypeAliases.js.diff @@ -82,4 +82,63 @@ 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 {}; // 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} ++ */ ++ ++==== 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.js b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js index 4d67274d17..39d2e28948 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js @@ -86,3 +86,42 @@ declare const _default: { Wrap: typeof Wrap; }; export = _default; + + +//// [DtsFileErrors] + + +out/conn.d.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +out/conn.d.ts(2,10): error TS2304: Cannot find name 'Conn'. +out/usage.d.ts(1,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) ==== + 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) ==== + 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')'? + /** + * @typedef {import("./conn")} 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 e597ed2ed7..35af772fcc 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.js.diff @@ -60,4 +60,43 @@ +declare const _default: { + Wrap: typeof Wrap; +}; -+export = _default; \ No newline at end of file ++export = _default; ++ ++ ++//// [DtsFileErrors] ++ ++ ++out/conn.d.ts(2,1): error TS2309: An export assignment cannot be used in a module with other exported elements. ++out/conn.d.ts(2,10): error TS2304: Cannot find name 'Conn'. ++out/usage.d.ts(1,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) ==== ++ 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) ==== ++ 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')'? ++ /** ++ * @typedef {import("./conn")} 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 e7ab5d1732..1fa8ef14fc 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/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/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.types b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types index 02e415dd5a..24160d5695 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.js").TaskGroup >y : TaskNode } 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/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/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.symbols b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols index f7dfd5ea5e..9eead7358d 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 3d463820b1..d5bd3af7e8 100644 --- a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.symbols.diff @@ -71,15 +71,7 @@ } === index.ts === -@@= skipped -36, +36 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)) -@@= skipped -48, +47 lines =@@ +@@= skipped -84, +84 lines =@@ ) { return a.length + b.length + c() + d() + e() + f() + g.length diff --git a/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types b/testdata/baselines/reference/submodule/conformance/moduleExportAssignment7.types index 666bc82208..87967f0f61 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/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.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.types index a66cb912fb..916120b4c4 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/typedefCrossModule2.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt index d48c75aeb1..ef2c18dda2 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt @@ -1,24 +1,18 @@ -mod1.js(3,23): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. -mod1.js(4,7): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. +mod1.js(3,23): error TS2300: Duplicate identifier 'Foo'. +mod1.js(4,7): error TS2300: Duplicate identifier 'Foo'. 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 TS2300: Duplicate identifier 'export='. mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. -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 (0 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} */ - ~~~ -!!! error TS2503: Cannot find namespace 'mod'. var bb; var bbb = new mod.Baz(); @@ -27,10 +21,10 @@ use.js(4,12): error TS2503: Cannot find namespace 'mod'. /** @typedef {number} Foo */ ~~~ -!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. +!!! error TS2300: Duplicate identifier 'Foo'. class Foo { } // should error ~~~ -!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. +!!! error TS2300: Duplicate identifier 'Foo'. /** @typedef {number} Bar */ exports.Bar = class { } diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols index 2104a285c8..25443ec9ff 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols @@ -25,7 +25,7 @@ var bbb = new mod.Baz(); /** @typedef {number} Foo */ class Foo { } // should error ->Foo : Symbol(Foo, Decl(mod1.js, 2, 4), Decl(mod1.js, 0, 0)) +>Foo : Symbol(Foo, Decl(mod1.js, 0, 0)) /** @typedef {number} Bar */ exports.Bar = class { } @@ -45,7 +45,7 @@ module.exports = { /** @typedef {number} Qux */ var Qux = 2; ->Qux : Symbol(Qux, Decl(mod1.js, 15, 4), Decl(mod1.js, 16, 3)) +>Qux : Symbol(Qux, Decl(mod1.js, 16, 3), Decl(mod1.js, 15, 4)) /** @typedef {number} Quid */ exports.Quid = 2; diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff index b01cc9dce5..7732e6515a 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.symbols.diff @@ -12,11 +12,7 @@ === mod1.js === // error - - /** @typedef {number} Foo */ - class Foo { } // should error -->Foo : Symbol(Foo, Decl(mod1.js, 0, 0)) -+>Foo : Symbol(Foo, Decl(mod1.js, 2, 4), Decl(mod1.js, 0, 0)) +@@= skipped -13, +13 lines =@@ /** @typedef {number} Bar */ exports.Bar = class { } @@ -36,12 +32,7 @@ Baz: class { } >Baz : Symbol(Baz, Decl(mod1.js, 9, 18)) -@@= skipped -31, +29 lines =@@ - - /** @typedef {number} Qux */ - var Qux = 2; -->Qux : Symbol(Qux, Decl(mod1.js, 16, 3), Decl(mod1.js, 15, 4)) -+>Qux : Symbol(Qux, Decl(mod1.js, 15, 4), Decl(mod1.js, 16, 3)) +@@= skipped -22, +20 lines =@@ /** @typedef {number} Quid */ exports.Quid = 2; diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types index e597356b31..d44be5cab2 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types @@ -9,11 +9,11 @@ var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ var b; ->b : any +>b : number /** @type {mod.Baz} */ var bb; ->bb : mod.Baz +>bb : number var bbb = new mod.Baz(); >bbb : Baz 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/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/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff deleted file mode 100644 index af290d6fc7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff deleted file mode 100644 index 6569dcf3a6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff index 6b73aa246f..c67d7cf39f 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff index aa131e44ee..197c247419 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.errors.txt.diff @@ -2,14 +2,13 @@ +++ new.jsEnumCrossFileExport.errors.txt @@= skipped -0, +0 lines =@@ - -+enumDef.js(16,18): error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. +index.js(4,17): error TS2503: Cannot find namespace 'Host'. +index.js(8,21): error TS2304: Cannot find name 'Host'. +index.js(13,11): error TS2503: Cannot find namespace 'Host'. +index.js(18,11): error TS2503: Cannot find namespace 'Host'. + + -+==== enumDef.js (1 errors) ==== ++==== enumDef.js (0 errors) ==== + var Host = {}; + Host.UserMetrics = {}; + /** @enum {number} */ @@ -26,8 +25,6 @@ + * @typedef {string} + */ + Host.UserMetrics.Blah = { -+ ~~~~ -+!!! error TS2339: Property 'Blah' does not exist on type '{ Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }'. + x: 12 + } +==== index.js (4 errors) ==== diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff index 6acccc05c0..fc2d0a0025 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsEnumCrossFileExport.types.diff @@ -6,8 +6,8 @@ var Host = {}; ->Host : typeof Host ->{} : {} -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>{} : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } Host.UserMetrics = {}; ->Host.UserMetrics = {} : typeof Host.UserMetrics @@ -15,11 +15,11 @@ ->Host : typeof Host ->UserMetrics : typeof Host.UserMetrics ->{} : {} -+>Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ++>Host.UserMetrics = {} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>{} : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } /** @enum {number} */ Host.UserMetrics.Action = { @@ -28,30 +28,26 @@ ->Host.UserMetrics : typeof Host.UserMetrics ->Host : typeof Host ->UserMetrics : typeof Host.UserMetrics -+>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } ++>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } >Action : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } >{ WindowDocked: 1, WindowUndocked: 2, ScriptsBreakpointSet: 3, TimelineStarted: 4,} : { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; } -@@= skipped -45, +45 lines =@@ - */ +@@= skipped -46, +46 lines =@@ Host.UserMetrics.Blah = { >Host.UserMetrics.Blah = { x: 12} : { x: number; } -->Host.UserMetrics.Blah : { x: number; } + >Host.UserMetrics.Blah : { x: number; } ->Host.UserMetrics : typeof Host.UserMetrics ->Host : typeof Host ->UserMetrics : typeof Host.UserMetrics -->Blah : { x: number; } -+>Host.UserMetrics.Blah : any -+>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; }; } -+>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; } -+>Blah : any ++>Host.UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } ++>Host : { UserMetrics: { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; }; } ++>UserMetrics : { Action: { WindowDocked: number; WindowUndocked: number; ScriptsBreakpointSet: number; TimelineStarted: number; }; Blah: { x: number; }; } + >Blah : { x: number; } >{ x: 12} : { x: number; } - x: 12 -@@= skipped -13, +13 lines =@@ +@@= skipped -12, +12 lines =@@ } === index.js === var Other = {}; diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff index fe7011b1d5..4190c3e450 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff @@ -3,7 +3,6 @@ @@= skipped -0, +0 lines =@@ - +typescript-eslint.js(12,17): error TS7019: Rest parameter 'configs' implicitly has an 'any[]' type. -+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) ==== @@ -30,7 +29,7 @@ + }, + }; + -+==== typescript-eslint.js (2 errors) ==== ++==== typescript-eslint.js (1 errors) ==== + /** + * @typedef {{ rules: Record }} Plugin + */ @@ -47,6 +46,4 @@ +!!! error TS7019: Rest parameter 'configs' implicitly has an 'any[]' type. + + 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/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.errors.txt.diff deleted file mode 100644 index b3e507b55d..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/callbackCrossModule.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.types.diff index c2187ec482..32ec3c6114 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/callbackCrossModule.types.diff @@ -27,23 +27,21 @@ >p : any >1 : 1 } -@@= skipped -20, +20 lines =@@ - === use.js === +@@= skipped -21, +21 lines =@@ /** @param {import('./mod1').Con} k */ function f(k) { -->f : (k: import("./mod1").Con) => any + >f : (k: import("./mod1").Con) => any ->k : import("mod1").Con -+>f : (k: any) => any -+>k : any ++>k : import("./mod1").Con if (1 === 2 - 1) { >1 === 2 - 1 : boolean -@@= skipped -14, +14 lines =@@ +@@= skipped -13, +13 lines =@@ } return k({ ok: true}) >k({ ok: true}) : any ->k : import("mod1").Con -+>k : any ++>k : import("./mod1").Con >{ ok: true} : { ok: boolean; } >ok : boolean >true : true \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff index be95625d15..f81fa8ea4d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff index 0158bec3cb..31fa95c869 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/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,10 +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 @@ -136,8 +136,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/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff index 44269de68f..6207fba2ab 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff @@ -11,12 +11,13 @@ +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. ++file.js(20,9): 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. + + -+==== file.js (6 errors) ==== ++==== file.js (7 errors) ==== /** * @namespace myTypes * @global @@ -50,10 +51,12 @@ export {myTypes}; -==== file2.js (1 errors) ==== -+==== file2.js (3 errors) ==== - import {myTypes} from './file.js'; -- ~~~~~~~ +- import {myTypes} from './file.js'; + ~~~~~~~ -!!! error TS18042: 'myTypes' is a type and cannot be imported in JavaScript files. Use 'import("./file.js").myTypes' in a JSDoc type annotation. ++!!! error TS2300: Duplicate identifier 'myTypes'. ++==== file2.js (3 errors) ==== ++ import {myTypes} from './file.js'; /** * @namespace testFnTypes diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff index 516be88695..b6046d8764 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt.diff @@ -8,13 +8,13 @@ +file.js(14,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,15): error TS2702: 'myTypes' only refers to a type, but is being used as a namespace here. +file.js(18,39): error TS2300: Duplicate identifier 'myTypes'. ++file.js(20,9): 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'); + + /** @@ -49,9 +49,7 @@ + } + + module.exports = {testFn, testFnTypes}; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== file.js (6 errors) ==== ++==== file.js (7 errors) ==== + /** + * @namespace myTypes + * @global @@ -83,4 +81,6 @@ + ~~~~~~~ +!!! error TS2300: Duplicate identifier 'myTypes'. + -+ exports.myTypes = myTypes; \ No newline at end of file ++ exports.myTypes = myTypes; ++ ~~~~~~~ ++!!! error TS2300: Duplicate identifier 'myTypes'. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.errors.txt.diff deleted file mode 100644 index b1bd799fbd..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.jsDeclarationsImportTypeBundled.errors.txt -+++ new.jsDeclarationsImportTypeBundled.errors.txt -@@= skipped -0, +0 lines =@@ -- -+folder/mod1.js(8,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -+ -+ -+==== folder/mod1.js (1 errors) ==== -+ /** -+ * @typedef {{x: number}} Item -+ */ -+ /** -+ * @type {Item}; -+ */ -+ const x = {x: 12}; -+ module.exports = x; -+ ~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== index.js (0 errors) ==== -+ /** @type {(typeof import("./folder/mod1"))[]} */ -+ const items = [{x: 12}]; -+ module.exports = items; \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff deleted file mode 100644 index 87be54e949..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff deleted file mode 100644 index 63315a780b..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff index 3fe51714b9..09c36190fb 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.types.diff @@ -32,10 +32,10 @@ this.another = ""; >this.another = "" : "" ->this.another : import("conn").Whatever -+>this.another : any ++>this.another : import("./conn").Whatever >this : this ->another : import("conn").Whatever -+>another : any ++>another : import("./conn").Whatever >"" : "" } } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff deleted file mode 100644 index cbea1dc733..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff index a95ad05e93..7225b551de 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff index 811f187d26..0595eaad40 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff @@ -16,7 +16,7 @@ */ constructor(x, y){} ->x : import("module").TaskGroup -+>x : any ++>x : import("./module.js").TaskGroup >y : TaskNode } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff deleted file mode 100644 index 9e66ced279..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff index b9969a5cd3..9bfe5f4620 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff index db60a68388..d14e966a91 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/moduleExportAssignment7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff index 8f88508c7d..8f210de5ed 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff @@ -21,13 +21,13 @@ ->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 : any return a.x + b.y + c() + d() + e() + f() + g.length @@ -49,11 +49,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 +67,12 @@ +>d : any +>e() : any +>e : any -+>f() : any -+>f : any + >f() : number +->f : import("mod").buz +->g.length : number +->g : string +->length : number ++>f : import("./mod").buz +>g.length : any +>g : any +>length : any @@ -94,7 +93,7 @@ === 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 @@ -103,18 +102,16 @@ f: import('./mod').buz, ->f : import("mod").buz -+>f : any ++>f : import("./mod").buz g: import('./mod').literal, >g : any -@@= skipped -25, +25 lines =@@ - >d : any +@@= skipped -26, +26 lines =@@ >e() : any >e : any -->f() : number + >f() : number ->f : import("mod").buz -+>f() : any -+>f : any ++>f : import("./mod").buz >g.length : any >g : any >length : any diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff deleted file mode 100644 index 09af25bcff..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/typedefCrossModule.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff index eab0e74fa6..c3c9f01fd9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.types.diff @@ -70,28 +70,24 @@ /** @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 ++>both1 : import("./mod1").Both + >{ type: 'a', x: 1 } : { type: "a"; x: 1; } + >type : "a" >'a' : "a" -->x : 1 -+>x : number - >1 : 1 +@@= skipped -9, +9 lines =@@ /** @type {import('./mod2').Both} */ var both2 = both1; ->both2 : import("mod2").Both ->both1 : import("mod1").A +>both2 : import("./mod2").Both -+>both1 : any ++>both1 : import("./mod1").A /** @type {import('./mod3').Both} */ var both3 = both2; ->both3 : import("mod3").Both ->both2 : import("mod2").A +>both3 : import("./mod3").Both -+>both2 : import("./mod2").Both ++>both2 : import("./mod2").A diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff index 0a4e1b8385..2a5e296181 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff @@ -1,34 +1,20 @@ --- old.typedefCrossModule2.errors.txt +++ new.typedefCrossModule2.errors.txt @@= skipped -0, +0 lines =@@ --mod1.js(3,23): error TS2300: Duplicate identifier 'Foo'. --mod1.js(4,7): error TS2300: Duplicate identifier 'Foo'. + mod1.js(3,23): error TS2300: Duplicate identifier 'Foo'. + mod1.js(4,7): error TS2300: Duplicate identifier 'Foo'. -mod1.js(9,23): error TS2300: Duplicate identifier 'Baz'. -mod1.js(11,5): error TS2300: Duplicate identifier 'Baz'. -- -- --==== use.js (0 errors) ==== -+mod1.js(3,23): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. -+mod1.js(4,7): error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. +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 TS2300: Duplicate identifier 'export='. +mod1.js(24,5): error TS2353: Object literal may only specify known properties, and 'Quack' does not exist in type '{ Baz: typeof Baz; }'. -+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) ==== - 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} */ -+ ~~~ -+!!! error TS2503: Cannot find namespace 'mod'. + + + ==== use.js (0 errors) ==== +@@= skipped -11, +15 lines =@@ var bb; var bbb = new mod.Baz(); @@ -37,13 +23,7 @@ // error /** @typedef {number} Foo */ - ~~~ --!!! error TS2300: Duplicate identifier 'Foo'. -+!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. - class Foo { } // should error - ~~~ --!!! error TS2300: Duplicate identifier 'Foo'. -+!!! error TS2395: Individual declarations in merged declaration 'Foo' must be all exported or all local. +@@= skipped -12, +12 lines =@@ /** @typedef {number} Bar */ exports.Bar = class { } @@ -71,7 +51,7 @@ // ok -@@= skipped -42, +56 lines =@@ +@@= skipped -19, +23 lines =@@ /** @typedef {number} Quid */ exports.Quid = 2; diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff index f33a595b97..6cedc9bf39 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff @@ -11,17 +11,7 @@ >require : any >'./mod1.js' : "./mod1.js" - /** @type {import("./mod1.js").Baz} */ - var b; -->b : number -+>b : any - - /** @type {mod.Baz} */ - var bb; -->bb : number -+>bb : mod.Baz - - var bbb = new mod.Baz(); +@@= skipped -17, +17 lines =@@ >bbb : Baz >new mod.Baz() : Baz >mod.Baz : typeof Baz @@ -30,7 +20,7 @@ >Baz : typeof Baz === mod1.js === -@@= skipped -30, +30 lines =@@ +@@= skipped -13, +13 lines =@@ /** @typedef {number} Bar */ exports.Bar = class { } >exports.Bar = class { } : typeof Bar diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule3.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule3.errors.txt.diff index 36296f2c15..ae9af08179 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/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/submoduleAccepted/conformance/typedefCrossModule4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule4.errors.txt.diff index d4e73b5e61..063060311b 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/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