diff --git a/internal/binder/binder.go b/internal/binder/binder.go index ca96bc4c37..90fe6ffb7a 100644 --- a/internal/binder/binder.go +++ b/internal/binder/binder.go @@ -73,6 +73,7 @@ type Binder struct { flowNodePool core.Pool[ast.FlowNode] flowListPool core.Pool[ast.FlowList] singleDeclarationsPool core.Pool[*ast.Node] + delayedTypeAliases []*ast.Node } type ActiveLabel struct { @@ -124,9 +125,32 @@ func bindSourceFile(file *ast.SourceFile, options *core.SourceFileAffectingCompi 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() @@ -686,8 +710,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/parser/reparser.go b/internal/parser/reparser.go index 0292d43484..dd2cb4f36b 100644 --- a/internal/parser/reparser.go +++ b/internal/parser/reparser.go @@ -79,7 +79,6 @@ func (p *Parser) reparseTags(parent *ast.Node, jsDoc []*ast.Node) { for _, tag := range j.AsJSDoc().Tags.Nodes { 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 index 491f957c42..d0af838614 100644 --- a/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/expandoFunctionContextualTypesJs.errors.txt @@ -1,11 +1,10 @@ input.js(5,48): error TS2304: Cannot find name 'P'. -input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. input.js(52,17): error TS2322: Type '{ color: string; }' is not assignable to type '{ color: "blue" | "red"; }'. Types of property 'color' are incompatible. Type 'string' is not assignable to type '"blue" | "red"'. -==== input.js (3 errors) ==== +==== input.js (2 errors) ==== /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ /** @@ -56,12 +55,8 @@ input.js(52,17): error TS2322: Type '{ color: string; }' is not assignable to ty * @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 }); ~~~~~ 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/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/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 202b95d863..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 }; diff --git a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt index 3331f7cf27..2b4385d035 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt @@ -2,9 +2,7 @@ context.js(4,14): error TS1340: Module './timer' does not refer to a type, but i 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 +13,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 +26,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 (4 errors) ==== /** * Imports * @@ -88,6 +84,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/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt index 339f44b69d..7fe3ce6bdd 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt @@ -3,12 +3,13 @@ file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. 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 (5 errors) ==== +==== file.js (6 errors) ==== /** * @namespace myTypes * @global @@ -39,6 +40,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 e5fd12a887..c115ae89c3 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,5 +32,5 @@ 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 b12f06b6fa..00b7e485fb 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.errors.txt @@ -3,13 +3,13 @@ file.js(10,51): error TS2300: Duplicate identifier 'myTypes'. file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. 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'); /** @@ -44,9 +44,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 (5 errors) ==== +==== file.js (6 errors) ==== /** * @namespace myTypes * @global @@ -76,4 +74,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 8f346643c9..ca47520240 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsImportAliasExposedWithinNamespaceCjs.symbols.diff @@ -39,8 +39,8 @@ ->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/jsDeclarationsTypedefAndImportTypes.errors.txt b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt index c319376abf..783bb406ba 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt @@ -1,10 +1,8 @@ -conn.js(11,1): error TS2309: An export assignment cannot be used in a module with other exported elements. usage.js(10,14): error TS2339: Property 'connItem' does not exist on type 'Wrap'. usage.js(12,14): error TS2339: Property 'another' does not exist on type 'Wrap'. -usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== conn.js (1 errors) ==== +==== conn.js (0 errors) ==== /** * @typedef {string | number} Whatever */ @@ -16,10 +14,8 @@ usage.js(16,1): error TS2309: An export assignment cannot be used in a module wi } module.exports = Conn; - ~~~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -==== usage.js (3 errors) ==== +==== usage.js (2 errors) ==== /** * @typedef {import("./conn")} Conn */ @@ -40,10 +36,6 @@ usage.js(16,1): error TS2309: An export assignment cannot be used in a module wi } 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/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 9159bcdbdb..28a8fbf2e5 100644 --- a/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt @@ -1,16 +1,11 @@ -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(11,38): error TS2304: Cannot find name 'P'. 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 @@ -29,9 +24,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 (3 errors) ==== +==== module.js (2 errors) ==== /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ /** @@ -63,11 +56,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 66e4dc7661..c26f71c094 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 : TaskGroup >y : TaskNode } diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt index 40ea387acb..92f98fe380 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt @@ -1,26 +1,18 @@ -MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. MW.js(8,10): error TS2339: Property 'compiler' does not exist on type 'MW'. -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} 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 (2 errors) ==== +==== MW.js (1 errors) ==== /** @typedef {import("./MC")} MC */ class MW { @@ -35,6 +27,4 @@ MW.js(12,1): error TS2309: An export assignment cannot be used in a module with } module.exports = MW; - ~~~~~~~~~~~~~~~~~~~ -!!! error TS2309: An export assignment cannot be used in a module with other exported elements. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt index a81017037a..2577e8668b 100644 --- a/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt @@ -1,28 +1,20 @@ -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(8,10): error TS2339: Property 'compiler' does not exist on type 'MW'. -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 (3 errors) ==== +==== MW.js (2 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')'? @@ -39,6 +31,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 8c07ecccc4..9081ec5b04 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 099a6e5460..e266a10ab3 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: () => number, g: any) => any >a : any >b : any >c : any >d : any >e : any ->f : any +>f : () => number >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 : () => number >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: () => number, g: any) => any a: import('./mod').Thing, >a : any @@ -159,7 +159,7 @@ function types( >e : any f: import('./mod').buz, ->f : any +>f : () => number 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 : () => number >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 index cec769759b..1007bdc830 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule.errors.txt @@ -1,17 +1,14 @@ -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) ==== +==== mod1.js (0 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 } diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt index d48c75aeb1..51e76e0712 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.errors.txt @@ -1,20 +1,17 @@ -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 (1 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ - ~~~ -!!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ ~~~ @@ -27,10 +24,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 aee4122252..909c9f8017 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 ec6c87f6dd..6e49c8f80c 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule2.types @@ -9,7 +9,7 @@ var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ var b; ->b : any +>b : number /** @type {mod.Baz} */ var bb; diff --git a/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt b/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt index cc76ff4dfb..11bd2db1cd 100644 --- a/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/typedefCrossModule3.errors.txt @@ -1,15 +1,12 @@ mod2.js(3,4): error TS2339: Property 'Foo' does not exist on type '{}'. -mod2.js(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. -==== mod2.js (2 errors) ==== +==== mod2.js (1 errors) ==== /** @typedef {number} Foo */ const ns = {}; ns.Foo = class {} ~~~ !!! error TS2339: Property 'Foo' does not exist on type '{}'. 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 2b56dab6c7..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/compiler/checkJsTypeDefNoUnusedLocalMarked.errors.txt.diff +++ /dev/null @@ -1,26 +0,0 @@ ---- old.checkJsTypeDefNoUnusedLocalMarked.errors.txt -+++ new.checkJsTypeDefNoUnusedLocalMarked.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 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. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff index 8cc2e3f334..2d417af926 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/expandoFunctionContextualTypesJs.errors.txt.diff @@ -4,13 +4,12 @@ - @@= skipped --1, +1 lines =@@ +input.js(5,48): error TS2304: Cannot find name 'P'. -+input.js(48,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +input.js(52,17): error TS2322: Type '{ color: string; }' is not assignable to type '{ color: "blue" | "red"; }'. + Types of property 'color' are incompatible. + Type 'string' is not assignable to type '"blue" | "red"'. + + -+==== input.js (3 errors) ==== ++==== input.js (2 errors) ==== + /** @typedef {{ color: "red" | "blue" }} MyComponentProps */ + + /** @@ -61,12 +60,8 @@ + * @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 }); + ~~~~~ diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff index e6da449bd1..261d99918c 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/jsDeclarationEmitExportAssignedFunctionWithExtraTypedefsMembers.errors.txt.diff @@ -3,11 +3,10 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 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 @@ -17,8 +16,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. + diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff index 2ae834d40c..39c0fa21ba 100644 --- a/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/compiler/moduleExportsTypeNoExcessPropertyCheckFromContainedLiteral.errors.txt.diff @@ -4,7 +4,6 @@ - @@= skipped --1, +1 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) ==== @@ -31,7 +30,7 @@ + }, + }; + -+==== typescript-eslint.js (2 errors) ==== ++==== typescript-eslint.js (1 errors) ==== + /** + * @typedef {{ rules: Record }} Plugin + */ @@ -48,6 +47,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. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff index 2c1cb5b2a6..a1946cdb9d 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsFunctionClassesCjsExportAssignment.errors.txt.diff @@ -7,9 +7,7 @@ +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) ==== @@ -20,7 +18,7 @@ + this.timeout = timeout; + } + module.exports = Timer; -+==== hook.js (2 errors) ==== ++==== hook.js (1 errors) ==== + /** + * @typedef {(arg: import("./context")) => void} HookHandler + ~~~~~~~~~~~~~~~~~~~ @@ -33,10 +31,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 (4 errors) ==== + /** + * Imports + * @@ -93,6 +89,4 @@ + } + } + module.exports = Context; -+ ~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff index 53d5cc4eb9..8b24e444cd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportAliasExposedWithinNamespace.errors.txt.diff @@ -7,13 +7,14 @@ +file.js(13,13): error TS2300: Duplicate identifier 'myTypes'. +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 (0 errors) ==== -+==== file.js (5 errors) ==== ++==== file.js (6 errors) ==== /** * @namespace myTypes * @global @@ -45,10 +46,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 c567ce510a..d4d289dbe3 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(13,13): error TS2300: Duplicate identifier 'myTypes'. +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 (5 errors) ==== ++==== file.js (6 errors) ==== + /** + * @namespace myTypes + * @global @@ -82,3 +80,5 @@ +!!! error TS2300: Duplicate identifier 'myTypes'. + + exports.myTypes = myTypes; ++ ~~~~~~~ ++!!! error TS2300: Duplicate identifier 'myTypes'. 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 a5394bab86..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsImportTypeBundled.errors.txt.diff +++ /dev/null @@ -1,23 +0,0 @@ ---- old.jsDeclarationsImportTypeBundled.errors.txt -+++ new.jsDeclarationsImportTypeBundled.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 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; 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 a69443eda3..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypeAliases.errors.txt.diff +++ /dev/null @@ -1,63 +0,0 @@ ---- old.jsDeclarationsTypeAliases.errors.txt -+++ new.jsDeclarationsTypeAliases.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 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" -+ } -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff index b57df579ed..776bc12028 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndImportTypes.errors.txt.diff @@ -3,13 +3,11 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+conn.js(11,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +usage.js(10,14): error TS2339: Property 'connItem' does not exist on type 'Wrap'. +usage.js(12,14): error TS2339: Property 'another' does not exist on type 'Wrap'. -+usage.js(16,1): error TS2309: An export assignment cannot be used in a module with other exported elements. + + -+==== conn.js (1 errors) ==== ++==== conn.js (0 errors) ==== + /** + * @typedef {string | number} Whatever + */ @@ -21,10 +19,8 @@ + } + + module.exports = Conn; -+ ~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + -+==== usage.js (3 errors) ==== ++==== usage.js (2 errors) ==== + /** + * @typedef {import("./conn")} Conn + */ @@ -45,10 +41,6 @@ + } + + module.exports = { -+ ~~~~~~~~~~~~~~~~~~ + Wrap -+ ~~~~~~~~ + }; -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + 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 fed430bfc6..0000000000 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefAndLatebound.errors.txt.diff +++ /dev/null @@ -1,33 +0,0 @@ ---- old.jsDeclarationsTypedefAndLatebound.errors.txt -+++ new.jsDeclarationsTypedefAndLatebound.errors.txt -@@= skipped -0, +-1 lines =@@ -- -@@= skipped --1, +1 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. -+ diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff index 4cf617b60f..52f3570031 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.errors.txt.diff @@ -3,19 +3,14 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 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(11,38): error TS2304: Cannot find name 'P'. +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 @@ -34,9 +29,7 @@ + } + + module.exports = MainThreadTasks; -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. -+==== module.js (3 errors) ==== ++==== module.js (2 errors) ==== + /** @typedef {'parseHTML'|'styleLayout'} TaskGroupIds */ + + /** @@ -68,11 +61,6 @@ + const taskNameToGroup = {}; + + module.exports = { -+ ~~~~~~~~~~~~~~~~~~ + taskGroups, -+ ~~~~~~~~~~~~~~~ + taskNameToGroup, -+ ~~~~~~~~~~~~~~~~~~~~ + }; -+ ~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff index e94038e6f9..ac237ffaed 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsDeclarationsTypedefPropertyAndExportAssignment.types.diff @@ -18,7 +18,7 @@ */ constructor(x, y){} ->x : import("module").TaskGroup -+>x : any ++>x : 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 index 50c492237b..59430c6015 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfClassExpression.errors.txt.diff @@ -3,29 +3,21 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 lines =@@ -+MC.js(5,1): error TS2309: An export assignment cannot be used in a module with other exported elements. +MW.js(8,10): error TS2339: Property 'compiler' does not exist on type 'MW'. -+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} 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 (2 errors) ==== ++==== MW.js (1 errors) ==== + /** @typedef {import("./MC")} MC */ + + class MW { @@ -40,6 +32,4 @@ + } + + module.exports = MW; -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff index a46248685e..ebacd0bce1 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/jsdocTypeReferenceToImportOfFunctionExpression.errors.txt.diff @@ -3,31 +3,23 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 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(8,10): error TS2339: Property 'compiler' does not exist on type 'MW'. -+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 (3 errors) ==== ++==== MW.js (2 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')'? @@ -44,6 +36,4 @@ + } + + module.exports = MW; -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. + diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.errors.txt.diff index cd97073159..3b5cef7912 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,38 +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(6,1): error TS2309: An export assignment cannot be used in a module with other exported elements. --==== mod.js (0 errors) ==== -+==== 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 + ~~~~~ @@ -61,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'. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff index 0065273908..e9c147630e 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/moduleExportAssignment7.types.diff @@ -29,13 +29,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: () => number, g: any) => any +>a : any +>b : any +>c : any +>d : any +>e : any -+>f : any ++>f : () => number +>g : any return a.x + b.y + c() + d() + e() + f() + g.length @@ -57,11 +57,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 @@ -80,8 +75,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 : () => number +>g.length : any +>g : any +>length : any @@ -102,7 +101,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: () => number, g: any) => any a: import('./mod').Thing, >a : any @@ -111,18 +110,16 @@ f: import('./mod').buz, ->f : import("mod").buz -+>f : any ++>f : () => number 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 : () => number >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 index 38256774be..36d12c7f20 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule.errors.txt.diff @@ -3,20 +3,17 @@ @@= skipped -0, +-1 lines =@@ - @@= skipped --1, +1 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) ==== ++==== mod1.js (0 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 + } diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff index 1921a5962d..6694396202 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.errors.txt.diff @@ -1,28 +1,23 @@ --- 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'. -+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 (0 errors) ==== -+==== use.js (2 errors) ==== ++==== use.js (1 errors) ==== var mod = require('./mod1.js'); /** @type {import("./mod1.js").Baz} */ -+ ~~~ -+!!! error TS2694: Namespace '"mod1".export=' has no exported member 'Baz'. var b; /** @type {mod.Baz} */ + ~~~ @@ -35,13 +30,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 -23, +30 lines =@@ /** @typedef {number} Bar */ exports.Bar = class { } @@ -69,7 +58,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 97373e3d4c..6044b381cd 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule2.types.diff @@ -11,10 +11,7 @@ >require : any >'./mod1.js' : "./mod1.js" - /** @type {import("./mod1.js").Baz} */ - var b; -->b : number -+>b : any +@@= skipped -11, +11 lines =@@ /** @type {mod.Baz} */ var bb; @@ -30,7 +27,7 @@ >Baz : typeof Baz === mod1.js === -@@= skipped -30, +30 lines =@@ +@@= skipped -19, +19 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 ff156cd3b8..3777d2b96a 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule3.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule3.errors.txt.diff @@ -4,10 +4,10 @@ -mod2.js(1,23): error TS2300: Duplicate identifier 'Foo'. -mod2.js(3,4): error TS2300: Duplicate identifier 'Foo'. +mod2.js(3,4): error TS2339: Property 'Foo' does not exist on type '{}'. -+mod2.js(4,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - ==== mod2.js (2 errors) ==== +-==== mod2.js (2 errors) ==== ++==== mod2.js (1 errors) ==== /** @typedef {number} Foo */ - ~~~ -!!! error TS2300: Duplicate identifier 'Foo'. @@ -19,7 +19,5 @@ -!!! related TS6203 mod2.js:1:23: 'Foo' was also declared here. +!!! error TS2339: Property 'Foo' does not exist on type '{}'. module.exports = ns; -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS2309: An export assignment cannot be used in a module with other exported elements. diff --git a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule4.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule4.errors.txt.diff index f3615f3918..0ece8798d9 100644 --- a/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule4.errors.txt.diff +++ b/testdata/baselines/reference/submoduleAccepted/conformance/typedefCrossModule4.errors.txt.diff @@ -1,23 +1,21 @@ --- old.typedefCrossModule4.errors.txt +++ new.typedefCrossModule4.errors.txt -@@= skipped -0, +0 lines =@@ +@@= skipped -0, +-1 lines =@@ -mod3.js(1,23): error TS2300: Duplicate identifier 'Foo'. -mod3.js(3,20): error TS2300: Duplicate identifier 'Foo'. -+mod3.js(3,1): error TS2309: An export assignment cannot be used in a module with other exported elements. - - +- +- -==== mod3.js (2 errors) ==== -+==== 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. - - +- +- +@@= skipped --1, +1 lines =@@ ++