53 lines
1.8 KiB
Plaintext
Raw Normal View History

== Why is this an issue?
Initially, TypeScript defined "internal modules" and "external modules":
2021-04-28 16:49:39 +02:00
* 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.
2021-04-28 16:49:39 +02:00
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]
2021-04-28 16:49:39 +02:00
----
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]
2021-04-28 16:49:39 +02:00
----
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[]