diff --git a/internal/checker/checker.go b/internal/checker/checker.go index 83a1bf78ef2..6f03cca00e1 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -5013,10 +5013,6 @@ func (c *Checker) checkModuleDeclaration(node *ast.Node) { } if ast.IsIdentifier(node.Name()) { c.checkCollisionsForDeclarationName(node, node.Name()) - if node.AsModuleDeclaration().Keyword == ast.KindModuleKeyword { - tokenRange := getNonModifierTokenRangeOfNode(node) - c.suggestionDiagnostics.Add(ast.NewDiagnostic(ast.GetSourceFileOfNode(node), tokenRange, diagnostics.A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead)) - } } c.checkExportsOnMergedDeclarations(node) symbol := c.getSymbolOfDeclaration(node) diff --git a/internal/checker/utilities.go b/internal/checker/utilities.go index 8faec72b231..af3dbfd2ed1 100644 --- a/internal/checker/utilities.go +++ b/internal/checker/utilities.go @@ -1262,14 +1262,6 @@ func minAndMax[T any](slice []T, getValue func(value T) int) (int, int) { return minValue, maxValue } -func getNonModifierTokenRangeOfNode(node *ast.Node) core.TextRange { - pos := node.Pos() - if last := ast.FindLastVisibleNode(node.ModifierNodes()); last != nil { - pos = last.Pos() - } - return scanner.GetRangeOfTokenAtPosition(ast.GetSourceFileOfNode(node), pos) -} - type FeatureMapEntry struct { lib string props []string diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 5404cfe32d0..1216f630d84 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -2082,19 +2082,20 @@ func (p *Parser) parseEnumDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers } func (p *Parser) parseModuleDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Statement { - keyword := ast.KindModuleKeyword if p.token == ast.KindGlobalKeyword { // global augmentation return p.parseAmbientExternalModuleDeclaration(pos, jsdoc, modifiers) } else if p.parseOptional(ast.KindNamespaceKeyword) { - keyword = ast.KindNamespaceKeyword + // namespace keyword always produces a namespace declaration + return p.parseModuleOrNamespaceDeclaration(pos, jsdoc, modifiers, false /*nested*/, false /*isIllegalModuleKeyword*/) } else { p.parseExpected(ast.KindModuleKeyword) if p.token == ast.KindStringLiteral { return p.parseAmbientExternalModuleDeclaration(pos, jsdoc, modifiers) } + // `module X {}` is illegal; use `namespace` instead + return p.parseModuleOrNamespaceDeclaration(pos, jsdoc, modifiers, false /*nested*/, true /*isIllegalModuleKeyword*/) } - return p.parseModuleOrNamespaceDeclaration(pos, jsdoc, modifiers, false /*nested*/, keyword) } func (p *Parser) parseAmbientExternalModuleDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList) *ast.Node { @@ -2133,7 +2134,7 @@ func (p *Parser) parseModuleBlock() *ast.Node { return p.finishNode(p.factory.NewModuleBlock(statements), pos) } -func (p *Parser) parseModuleOrNamespaceDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList, nested bool, keyword ast.Kind) *ast.Node { +func (p *Parser) parseModuleOrNamespaceDeclaration(pos int, jsdoc jsdocScannerInfo, modifiers *ast.ModifierList, nested bool, isIllegalModuleKeyword bool) *ast.Node { saveHasAwaitIdentifier := p.statementHasAwaitIdentifier var name *ast.Node if nested { @@ -2141,17 +2142,21 @@ func (p *Parser) parseModuleOrNamespaceDeclaration(pos int, jsdoc jsdocScannerIn } else { name = p.parseIdentifier() } + if isIllegalModuleKeyword && !nested { + errorStart := scanner.SkipTrivia(p.sourceText, name.Pos()) + p.parseErrorAt(errorStart, name.End(), diagnostics.A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead) + } var body *ast.Node if p.parseOptional(ast.KindDotToken) { implicitExport := p.factory.NewModifier(ast.KindExportKeyword) implicitExport.Loc = core.NewTextRange(p.nodePos(), p.nodePos()) implicitExport.Flags = ast.NodeFlagsReparsed implicitModifiers := p.newModifierList(implicitExport.Loc, p.nodeSlicePool.NewSlice1(implicitExport)) - body = p.parseModuleOrNamespaceDeclaration(p.nodePos(), 0 /*jsdoc*/, implicitModifiers, true /*nested*/, keyword) + body = p.parseModuleOrNamespaceDeclaration(p.nodePos(), 0 /*jsdoc*/, implicitModifiers, true /*nested*/, isIllegalModuleKeyword) } else { body = p.parseModuleBlock() } - result := p.finishNode(p.factory.NewModuleDeclaration(modifiers, keyword, name, body), pos) + result := p.finishNode(p.factory.NewModuleDeclaration(modifiers, ast.KindNamespaceKeyword, name, body), pos) p.withJSDoc(result, jsdoc) p.checkJSSyntax(result) p.statementHasAwaitIdentifier = saveHasAwaitIdentifier diff --git a/internal/printer/printer_test.go b/internal/printer/printer_test.go index 0d0628f4ea3..f36eb5df522 100644 --- a/internal/printer/printer_test.go +++ b/internal/printer/printer_test.go @@ -255,8 +255,6 @@ func TestEmit(t *testing.T) { {title: "EnumDeclaration#1", input: `enum a{}`, output: "enum a {\n}"}, {title: "EnumDeclaration#2", input: `enum a{b}`, output: "enum a {\n b\n}"}, {title: "EnumDeclaration#3", input: `enum a{b=c}`, output: "enum a {\n b = c\n}"}, - {title: "ModuleDeclaration#1", input: `module a{}`, output: "module a { }"}, - {title: "ModuleDeclaration#2", input: `module a.b{}`, output: "module a.b { }"}, {title: "ModuleDeclaration#3", input: `module "a";`, output: "module \"a\";"}, {title: "ModuleDeclaration#4", input: `module "a"{}`, output: "module \"a\" { }"}, {title: "ModuleDeclaration#5", input: `namespace a{}`, output: "namespace a { }"}, diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.errors.txt b/testdata/baselines/reference/compiler/reachabilityChecks11.errors.txt index 9be504154ac..fa0031e84af 100644 --- a/testdata/baselines/reference/compiler/reachabilityChecks11.errors.txt +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.errors.txt @@ -11,24 +11,24 @@ reachabilityChecks11.ts(69,5): error TS7027: Unreachable code detected. // while (true); var x = 1; - module A { + namespace A { while (true); let x; ~~~~~~ !!! error TS7027: Unreachable code detected. } - module A1 { + namespace A1 { do {} while(true); - module A { + namespace A { interface F {} } } - module A2 { + namespace A2 { while (true); - module A { - ~~~~~~~~~~ + namespace A { + ~~~~~~~~~~~~~ var x = 1; ~~~~~~~~~~~~~~~~~~ } @@ -36,15 +36,15 @@ reachabilityChecks11.ts(69,5): error TS7027: Unreachable code detected. !!! error TS7027: Unreachable code detected. } - module A3 { + namespace A3 { while (true); type T = string; } - module A4 { + namespace A4 { while (true); - module A { - ~~~~~~~~~~ + namespace A { + ~~~~~~~~~~~~~ const enum E { X } ~~~~~~~~~~~~~~~~~~~~~~~~~~ } @@ -73,9 +73,9 @@ reachabilityChecks11.ts(69,5): error TS7027: Unreachable code detected. !!! error TS7027: Unreachable code detected. } - module B { + namespace B { for (; ;); - module C { + namespace C { } } diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.js b/testdata/baselines/reference/compiler/reachabilityChecks11.js index c44259c4b8a..24867f18398 100644 --- a/testdata/baselines/reference/compiler/reachabilityChecks11.js +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.js @@ -4,33 +4,33 @@ // while (true); var x = 1; -module A { +namespace A { while (true); let x; } -module A1 { +namespace A1 { do {} while(true); - module A { + namespace A { interface F {} } } -module A2 { +namespace A2 { while (true); - module A { + namespace A { var x = 1; } } -module A3 { +namespace A3 { while (true); type T = string; } -module A4 { +namespace A4 { while (true); - module A { + namespace A { const enum E { X } } } @@ -51,9 +51,9 @@ function f2() { } } -module B { +namespace B { for (; ;); - module C { + namespace C { } } diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.symbols b/testdata/baselines/reference/compiler/reachabilityChecks11.symbols index e6bab4abde1..63aae332adc 100644 --- a/testdata/baselines/reference/compiler/reachabilityChecks11.symbols +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.symbols @@ -5,7 +5,7 @@ var x = 1; >x : Symbol(x, Decl(reachabilityChecks11.ts, 1, 3)) -module A { +namespace A { >A : Symbol(A, Decl(reachabilityChecks11.ts, 1, 10)) while (true); @@ -13,23 +13,23 @@ module A { >x : Symbol(x, Decl(reachabilityChecks11.ts, 5, 7)) } -module A1 { +namespace A1 { >A1 : Symbol(A1, Decl(reachabilityChecks11.ts, 6, 1)) do {} while(true); - module A { + namespace A { >A : Symbol(A, Decl(reachabilityChecks11.ts, 9, 22)) interface F {} ->F : Symbol(F, Decl(reachabilityChecks11.ts, 10, 14)) +>F : Symbol(F, Decl(reachabilityChecks11.ts, 10, 17)) } } -module A2 { +namespace A2 { >A2 : Symbol(A2, Decl(reachabilityChecks11.ts, 13, 1)) while (true); - module A { + namespace A { >A : Symbol(A, Decl(reachabilityChecks11.ts, 16, 17)) var x = 1; @@ -37,7 +37,7 @@ module A2 { } } -module A3 { +namespace A3 { >A3 : Symbol(A3, Decl(reachabilityChecks11.ts, 20, 1)) while (true); @@ -45,15 +45,15 @@ module A3 { >T : Symbol(T, Decl(reachabilityChecks11.ts, 23, 17)) } -module A4 { +namespace A4 { >A4 : Symbol(A4, Decl(reachabilityChecks11.ts, 25, 1)) while (true); - module A { + namespace A { >A : Symbol(A, Decl(reachabilityChecks11.ts, 28, 17)) const enum E { X } ->E : Symbol(E, Decl(reachabilityChecks11.ts, 29, 14)) +>E : Symbol(E, Decl(reachabilityChecks11.ts, 29, 17)) >X : Symbol(E.X, Decl(reachabilityChecks11.ts, 30, 22)) } } @@ -84,11 +84,11 @@ function f2() { } } -module B { +namespace B { >B : Symbol(B, Decl(reachabilityChecks11.ts, 48, 1)) for (; ;); - module C { + namespace C { >C : Symbol(C, Decl(reachabilityChecks11.ts, 51, 14)) } } diff --git a/testdata/baselines/reference/compiler/reachabilityChecks11.types b/testdata/baselines/reference/compiler/reachabilityChecks11.types index 10cf27d433f..a3c34e9f1c0 100644 --- a/testdata/baselines/reference/compiler/reachabilityChecks11.types +++ b/testdata/baselines/reference/compiler/reachabilityChecks11.types @@ -6,7 +6,7 @@ var x = 1; >x : number >1 : 1 -module A { +namespace A { >A : typeof A while (true); @@ -16,24 +16,24 @@ module A { >x : any } -module A1 { +namespace A1 { >A1 : typeof A1 do {} while(true); >true : true - module A { + namespace A { interface F {} } } -module A2 { +namespace A2 { >A2 : typeof A2 while (true); >true : true - module A { + namespace A { >A : typeof A var x = 1; @@ -42,7 +42,7 @@ module A2 { } } -module A3 { +namespace A3 { >A3 : typeof A3 while (true); @@ -52,13 +52,13 @@ module A3 { >T : string } -module A4 { +namespace A4 { >A4 : typeof A4 while (true); >true : true - module A { + namespace A { const enum E { X } >E : E >X : E.X @@ -93,11 +93,11 @@ function f2() { } } -module B { +namespace B { >B : typeof B for (; ;); - module C { + namespace C { } } diff --git a/testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt b/testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt index c07e76a48e7..d8ab744fd24 100644 --- a/testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt @@ -1,8 +1,9 @@ +escapedIdentifiers.ts(25,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. escapedIdentifiers.ts(37,12): error TS2564: Property 'foo1' has no initializer and is not definitely assigned in the constructor. escapedIdentifiers.ts(40,12): error TS2564: Property 'foo2' has no initializer and is not definitely assigned in the constructor. -==== escapedIdentifiers.ts (2 errors) ==== +==== escapedIdentifiers.ts (3 errors) ==== /* 0 .. \u0030 9 .. \u0039 @@ -28,6 +29,8 @@ escapedIdentifiers.ts(40,12): error TS2564: Property 'foo2' has no initializer a export var baz1: number; } declare module moduleType\u0032 { + ~~~~~~~~~~~~~~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. export var baz2: number; } diff --git a/testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt.diff deleted file mode 100644 index 557a1343d13..00000000000 --- a/testdata/baselines/reference/submodule/compiler/escapedIdentifiers.errors.txt.diff +++ /dev/null @@ -1,22 +0,0 @@ ---- old.escapedIdentifiers.errors.txt -+++ new.escapedIdentifiers.errors.txt -@@= skipped -0, +0 lines =@@ --escapedIdentifiers.ts(25,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. - escapedIdentifiers.ts(37,12): error TS2564: Property 'foo1' has no initializer and is not definitely assigned in the constructor. - escapedIdentifiers.ts(40,12): error TS2564: Property 'foo2' has no initializer and is not definitely assigned in the constructor. - - --==== escapedIdentifiers.ts (3 errors) ==== -+==== escapedIdentifiers.ts (2 errors) ==== - /* - 0 .. \u0030 - 9 .. \u0039 -@@= skipped -28, +27 lines =@@ - export var baz1: number; - } - declare module moduleType\u0032 { -- ~~~~~~~~~~~~~~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. - export var baz2: number; - } - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt b/testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt new file mode 100644 index 00000000000..0097455e822 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt @@ -0,0 +1,46 @@ +decl.d.ts(1,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. +decl.d.ts(2,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. +decl.d.ts(7,15): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. +decl.d.ts(8,15): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. +foo.ts(2,8): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. +foo.ts(3,8): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. +foo.ts(4,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. +foo.ts(5,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + + +==== foo.ts (4 errors) ==== + // Error + module notok { } + ~~~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + module not.ok { } + ~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + declare module bad { } + ~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + declare module also.bad { } + ~~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + + // Still the only way to do it + declare module "good" { } + +==== decl.d.ts (4 errors) ==== + declare module foo { } + ~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + declare module foo.bar { } + ~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + + // Still the only way to do it + declare module "alsogood" { } + + export module exported { } + ~~~~~~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + export module exported.sub { } + ~~~~~~~~ +!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt.diff index 0ac03eff1b8..de16de510c3 100644 --- a/testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/moduleKeywordDeprecated.errors.txt.diff @@ -1,62 +1,63 @@ --- old.moduleKeywordDeprecated.errors.txt +++ new.moduleKeywordDeprecated.errors.txt @@= skipped -0, +0 lines =@@ --decl.d.ts(1,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. --decl.d.ts(2,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + decl.d.ts(1,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + decl.d.ts(2,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -decl.d.ts(2,20): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. --decl.d.ts(7,15): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. --decl.d.ts(8,15): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + decl.d.ts(7,15): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + decl.d.ts(8,15): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -decl.d.ts(8,24): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. --foo.ts(2,8): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. --foo.ts(3,8): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + foo.ts(2,8): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + foo.ts(3,8): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -foo.ts(3,12): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. --foo.ts(4,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. --foo.ts(5,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + foo.ts(4,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + foo.ts(5,16): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -foo.ts(5,21): error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. - - -==== foo.ts (6 errors) ==== -- // Error -- module notok { } -- ~~~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- module not.ok { } -- ~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. ++ ++ ++==== foo.ts (4 errors) ==== + // Error + module notok { } + ~~~~~ +@@= skipped -19, +15 lines =@@ + module not.ok { } + ~~~ + !!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. - ~~ -!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- declare module bad { } -- ~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- declare module also.bad { } -- ~~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + declare module bad { } + ~~~ + !!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + declare module also.bad { } + ~~~~ + !!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. - ~~~ -!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- -- // Still the only way to do it -- declare module "good" { } -- + + // Still the only way to do it + declare module "good" { } + -==== decl.d.ts (6 errors) ==== -- declare module foo { } -- ~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- declare module foo.bar { } -- ~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. ++==== decl.d.ts (4 errors) ==== + declare module foo { } + ~~~ + !!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + declare module foo.bar { } + ~~~ + !!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. - ~~~ -!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- -- // Still the only way to do it -- declare module "alsogood" { } -- -- export module exported { } -- ~~~~~~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- export module exported.sub { } -- ~~~~~~~~ + + // Still the only way to do it + declare module "alsogood" { } +@@= skipped -32, +26 lines =@@ + !!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + export module exported.sub { } + ~~~~~~~~ -!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. - ~~~ --!!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. -- -+ \ No newline at end of file + !!! error TS1540: A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead. + \ No newline at end of file diff --git a/testdata/tests/cases/compiler/reachabilityChecks11.ts b/testdata/tests/cases/compiler/reachabilityChecks11.ts index 81dbcf3c7ad..abcafb41133 100644 --- a/testdata/tests/cases/compiler/reachabilityChecks11.ts +++ b/testdata/tests/cases/compiler/reachabilityChecks11.ts @@ -4,33 +4,33 @@ // while (true); var x = 1; -module A { +namespace A { while (true); let x; } -module A1 { +namespace A1 { do {} while(true); - module A { + namespace A { interface F {} } } -module A2 { +namespace A2 { while (true); - module A { + namespace A { var x = 1; } } -module A3 { +namespace A3 { while (true); type T = string; } -module A4 { +namespace A4 { while (true); - module A { + namespace A { const enum E { X } } } @@ -51,9 +51,9 @@ function f2() { } } -module B { +namespace B { for (; ;); - module C { + namespace C { } }