-
Notifications
You must be signed in to change notification settings - Fork 13k
Implement TypeScript 6.0 deprecation of module
keyword for namespace declarations
#62390
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 4 commits
88b137f
7cbbb7e
381d4a6
dcfee6e
3a60026
0ebcdd1
e6ee96d
8387013
492692e
e93fa38
6e09dc2
116285f
3e0cdbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1825,6 +1825,10 @@ | |
"code": 1540, | ||
"reportsDeprecated": true | ||
}, | ||
"The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead.": { | ||
|
||
"category": "Error", | ||
"code": 1547 | ||
}, | ||
"Type-only import of an ECMAScript module from a CommonJS module must have a 'resolution-mode' attribute.": { | ||
"category": "Error", | ||
"code": 1541 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module.d.ts(1,9): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== module.d.ts (1 errors) ==== | ||
declare module Point { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
export var Origin: { x: number; y: number; } | ||
} | ||
|
||
==== function.d.ts (0 errors) ==== | ||
declare function Point(): { x: number; y: number; } | ||
|
||
==== test.ts (0 errors) ==== | ||
var cl: { x: number; y: number; } | ||
var cl = Point(); | ||
var cl = Point.Origin; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
module.d.ts(1,9): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== module.d.ts (1 errors) ==== | ||
declare module Point { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
export var Origin: { x: number; y: number; } | ||
} | ||
|
||
==== function.ts (0 errors) ==== | ||
function Point() { | ||
return { x: 0, y: 0 }; | ||
} | ||
|
||
==== test.ts (0 errors) ==== | ||
var cl: { x: number; y: number; } | ||
var cl = Point(); | ||
var cl = Point.Origin; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
EnumAndModuleWithSameNameAndCommonRoot.ts(5,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== EnumAndModuleWithSameNameAndCommonRoot.ts (1 errors) ==== | ||
enum enumdule { | ||
Red, Blue | ||
} | ||
|
||
module enumdule { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
export class Point { | ||
constructor(public x: number, public y: number) { } | ||
} | ||
} | ||
|
||
var x: enumdule; | ||
var x = enumdule.Red; | ||
|
||
var y: { x: number; y: number }; | ||
var y = new enumdule.Point(0, 0); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
ExportClassWhichExtendsInterfaceWithInaccessibleType.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== ExportClassWhichExtendsInterfaceWithInaccessibleType.ts (1 errors) ==== | ||
module A { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
interface Point { | ||
x: number; | ||
y: number; | ||
|
||
fromOrigin(p: Point): number; | ||
} | ||
|
||
export class Point2d implements Point { | ||
constructor(public x: number, public y: number) { } | ||
|
||
fromOrigin(p: Point) { | ||
return 1; | ||
} | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== ExportFunctionWithAccessibleTypesInParameterAndReturnTypeAnnotation.ts (1 errors) ==== | ||
module A { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
export class Point { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
export class Line { | ||
constructor(public start: Point, public end: Point) { } | ||
} | ||
|
||
export function fromOrigin(p: Point): Line { | ||
return new Line({ x: 0, y: 0 }, p); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== ExportFunctionWithInaccessibleTypesInParameterTypeAnnotation.ts (1 errors) ==== | ||
module A { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
class Point { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
export class Line { | ||
constructor(public start: Point, public end: Point) { } | ||
} | ||
|
||
export function fromOrigin(p: Point): Line { | ||
return new Line({ x: 0, y: 0 }, p); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== ExportFunctionWithInaccessibleTypesInReturnTypeAnnotation.ts (1 errors) ==== | ||
module A { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
export class Point { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
class Line { | ||
constructor(public start: Point, public end: Point) { } | ||
} | ||
|
||
export function fromOrigin(p: Point): Line { | ||
return new Line({ x: 0, y: 0 }, p); | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== ExportObjectLiteralAndObjectTypeLiteralWithAccessibleTypesInNestedMemberTypeAnnotations.ts (1 errors) ==== | ||
module A { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
class Point { | ||
constructor(public x: number, public y: number) { } | ||
} | ||
|
||
export var UnitSquare : { | ||
top: { left: Point, right: Point }, | ||
bottom: { left: Point, right: Point } | ||
} = null; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
ExportVariableWithInaccessibleTypeInTypeAnnotation.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== ExportVariableWithInaccessibleTypeInTypeAnnotation.ts (1 errors) ==== | ||
module A { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
export interface Point { | ||
x: number; | ||
y: number; | ||
} | ||
|
||
// valid since Point is exported | ||
export var Origin: Point = { x: 0, y: 0 }; | ||
|
||
interface Point3d extends Point { | ||
z: number; | ||
} | ||
|
||
// invalid Point3d is not exported | ||
export var Origin3d: Point3d = { x: 0, y: 0, z: 0 }; | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
function.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
module.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
module.ts(2,12): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== function.ts (1 errors) ==== | ||
module A { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
export function Point() { | ||
return { x: 0, y: 0 }; | ||
} | ||
} | ||
|
||
==== module.ts (2 errors) ==== | ||
module B { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
export module Point { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
export var Origin = { x: 0, y: 0 }; | ||
} | ||
} | ||
|
||
==== test.ts (0 errors) ==== | ||
var fn: () => { x: number; y: number }; | ||
var fn = A.Point; | ||
|
||
var cl: { x: number; y: number; } | ||
var cl = B.Point.Origin; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
ModuleAndEnumWithSameNameAndCommonRoot.ts(1,1): error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
|
||
==== ModuleAndEnumWithSameNameAndCommonRoot.ts (1 errors) ==== | ||
module enumdule { | ||
~~~~~~ | ||
!!! error TS1547: The 'module' keyword is not allowed for namespace declarations. Use the 'namespace' keyword instead. | ||
|
||
export class Point { | ||
constructor(public x: number, public y: number) { } | ||
} | ||
} | ||
|
||
enum enumdule { | ||
Red, Blue | ||
} | ||
|
||
var x: enumdule; | ||
var x = enumdule.Red; | ||
|
||
var y: { x: number; y: number }; | ||
var y = new enumdule.Point(0, 0); |
Uh oh!
There was an error while loading. Please reload this page.