53 lines
1.8 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

== Why is this an issue?
Initially, TypeScript defined "internal modules" and "external modules":
* Internal modules: The `module` keyword was introduced in TypeScript to define internal modules. Internal modules were used to group classes, interfaces, and functions into logical units.
* External modules refer to JavaScript modules, introduced in ECMAScript 2015. In TypeScript, just as in JavaScript (after ECMAScript 2015), any file containing a top-level `import` or `export` is considered a module.
However, in order to avoid confusion with similarly named terms, `module` was deprecated in favor of the `namespace` keyword, and "external modules" became simply "modules", as to align with ECMAScript 2015s terminology.
Now that ``++namespace++`` is available, the use of ``++module++`` is deprecated because it does the same thing, and its use could confuse maintainers unaware of the history of the language. Therefore, the use of `module` is discouraged in TypeScript code.
[source,javascript,diff-id=1,diff-type=noncompliant]
----
module myMod { // Noncompliant
// ...
}
----
Anywhere the `module` keyword was used when declaring an internal module, the `namespace` keyword should be used instead.
[source,javascript,diff-id=1,diff-type=compliant]
----
namespace myMod {
// ...
}
----
== Resources
=== Documentation
* TypeScript Documentation - https://www.typescriptlang.org/docs/handbook/namespaces.html[Namespaces]
* TypeScript Documentation - https://www.typescriptlang.org/docs/handbook/modules.html[Modules]
* ECMAScript - https://262.ecma-international.org/6.0/[ECMAScript 2015]
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Create a "namespace" instead of "module" here.
=== Highlighting
``++module++``
endif::env-github,rspecator-view[]