Skip to content

Commit b6e4c25

Browse files
RyanCavanaughjakebailey
authored andcommitted
Deprecate module syntax (microsoft#62876)
1 parent 2743954 commit b6e4c25

File tree

104 files changed

+487
-242
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+487
-242
lines changed

src/compiler/checker.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,6 @@ import {
347347
getNamespaceDeclarationNode,
348348
getNewTargetContainer,
349349
getNonAugmentationDeclaration,
350-
getNonModifierTokenPosOfNode,
351350
getNormalizedAbsolutePath,
352351
getObjectFlags,
353352
getOriginalNode,
@@ -47791,12 +47790,7 @@ export function createTypeChecker(host: TypeCheckerHost): TypeChecker {
4779147790
if (isIdentifier(node.name)) {
4779247791
checkCollisionsForDeclarationName(node, node.name);
4779347792
if (!(node.flags & (NodeFlags.Namespace | NodeFlags.GlobalAugmentation))) {
47794-
const sourceFile = getSourceFileOfNode(node);
47795-
const pos = getNonModifierTokenPosOfNode(node);
47796-
const span = getSpanOfTokenAtPosition(sourceFile, pos);
47797-
suggestionDiagnostics.add(
47798-
createFileDiagnostic(sourceFile, span.start, span.length, Diagnostics.A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead),
47799-
);
47793+
error(node.name, Diagnostics.A_namespace_declaration_should_not_be_declared_using_the_module_keyword_Please_use_the_namespace_keyword_instead);
4780047794
}
4780147795
}
4780247796

src/compiler/diagnosticMessages.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1821,9 +1821,8 @@
18211821
"code": 1539
18221822
},
18231823
"A 'namespace' declaration should not be declared using the 'module' keyword. Please use the 'namespace' keyword instead.": {
1824-
"category": "Suggestion",
1825-
"code": 1540,
1826-
"reportsDeprecated": true
1824+
"category": "Error",
1825+
"code": 1540
18271826
},
18281827
"Type-only import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute.": {
18291828
"category": "Error",

src/compiler/utilities.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,16 +1281,6 @@ export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFil
12811281
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastDecorator.end);
12821282
}
12831283

1284-
/** @internal */
1285-
export function getNonModifierTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number {
1286-
const lastModifier = !nodeIsMissing(node) && canHaveModifiers(node) && node.modifiers ? last(node.modifiers) : undefined;
1287-
if (!lastModifier) {
1288-
return getTokenPosOfNode(node, sourceFile);
1289-
}
1290-
1291-
return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastModifier.end);
1292-
}
1293-
12941284
/** @internal */
12951285
export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string {
12961286
return getTextOfNodeFromSourceText(sourceFile.text, node, includeTrivia);

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.errors.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts(26,26): error
1414
}
1515
}
1616

17-
module A{
17+
namespace A{
1818
// expected error
1919
export class Point {
2020
~~~~~

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace A {
88
}
99
}
1010

11-
module A{
11+
namespace A{
1212
// expected error
1313
export class Point {
1414
origin: number;

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ namespace A {
1515
}
1616
}
1717

18-
module A{
18+
namespace A{
1919
>A : Symbol(A, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 0, 0), Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 5, 1))
2020

2121
// expected error
2222
export class Point {
23-
>Point : Symbol(Point, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 7, 9))
23+
>Point : Symbol(Point, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 7, 12))
2424

2525
origin: number;
2626
>origin : Symbol(Point.origin, Decl(TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.ts, 9, 24))

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedClassesOfTheSameName.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ namespace A {
1919
}
2020
}
2121

22-
module A{
22+
namespace A{
2323
>A : typeof A
2424
> : ^^^^^^^^
2525

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace A.B {
55
export var x: number;
66
}
77

8-
module A{
8+
namespace A{
99
namespace B {
1010
export var x: string;
1111
}

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.symbols

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ namespace A.B {
99
>x : Symbol(x, Decl(TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts, 1, 14))
1010
}
1111

12-
module A{
12+
namespace A{
1313
>A : Symbol(A, Decl(TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts, 0, 0), Decl(TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts, 2, 1))
1414

1515
namespace B {
16-
>B : Symbol(B, Decl(TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts, 4, 9))
16+
>B : Symbol(B, Decl(TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts, 4, 12))
1717

1818
export var x: string;
1919
>x : Symbol(x, Decl(TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.ts, 6, 18))

tests/baselines/reference/TwoInternalModulesThatMergeEachWithExportedModulesOfTheSameName.types

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ namespace A.B {
1212
> : ^^^^^^
1313
}
1414

15-
module A{
15+
namespace A{
1616
>A : typeof A
1717
> : ^^^^^^^^
1818

0 commit comments

Comments
 (0)