You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Search Terms: module, namespace, module vs namespace, module keyword
Suggestion:
The use of the module keyword has been replaced with namespace, except when actually declaring ES6 modules in a declaration file. However, in my personal experience I still see new developers getting confused about ES6 modules and the TS module keyword, even through it's well documented, because TS silently supports the module keyword for backwards compatibility.
Why not deprecate the use of the module keyword where it "shouldn't" be used anymore? Emit an error or a warning by default, suppressible with a tsconfig flag for backwards compatibility?
Code
// Example of needless namespacingexport module Shapes{exportclassCircle{}exportclassSquare{}}
Expected behavior:
Some kind of warning that module here should be namespace, and that a namespace is not needed in an ES6 module using export.
I realize you could argue a linter is a better place to provide this kind of check, but the idea is to help users during the learning process who will easily fall into the confusion of module as a namespace vs ES6 module.
Actual behavior:
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
TypeScript Version: 2.7.0-dev.201xxxxx
Search Terms: module, namespace, module vs namespace, module keyword
Suggestion:
The use of the
module
keyword has been replaced withnamespace
, except when actually declaring ES6 modules in a declaration file. However, in my personal experience I still see new developers getting confused about ES6 modules and the TSmodule
keyword, even through it's well documented, because TS silently supports themodule
keyword for backwards compatibility.Why not deprecate the use of the
module
keyword where it "shouldn't" be used anymore? Emit an error or a warning by default, suppressible with a tsconfig flag for backwards compatibility?Code
Expected behavior:
Some kind of warning that
module
here should benamespace
, and that anamespace
is not needed in an ES6 module usingexport
.I realize you could argue a linter is a better place to provide this kind of check, but the idea is to help users during the learning process who will easily fall into the confusion of
module
as a namespace vs ES6 module.Actual behavior:
Playground Link:
Related Issues:
The text was updated successfully, but these errors were encountered: