-
Notifications
You must be signed in to change notification settings - Fork 13k
Description
In TypeScript 1.5, we introduced the namespace
keyword so people could stop distinguishing between "internal modules" and "external modules". This allowed developers to more clearly say
- "namespaces" in place of "internal modules", and
- "modules" in place of "external modules"/"ECMAScript or CommonJS modules".
In general, we think namespaces should be used sparingly (instead just using modules when needed); however, we really don't want anyone using the module
keyword anymore for them. This is for a few reasons:
- We've had a perfectly good, clearer alternative keyword for over 10 years now
- We may want to use the
module
keyword down the line in JavaScript itself
In recent years, our language service started the module
keyword with a deprecation diagnostic. In editors like VS Code, this shows up as a strikethrough:

We have also ensured that DefinitelyTyped is clear of the module
keyword for any namespace declarations, so no @types
package published in the last two years has leveraged the legacy syntax.
But now in TypeScript 6.0, we will deprecate the usage of the module
keyword for namespaces. If a namespace is declared with the module
keyword, TypeScript will issue an error that can only be suppressed via ignoreDeprecations
. TypeScript 7.0 will always error on its usage.
These errors will apply to all locations - using the module
keyword for namespaces will be an error even in declaration files (.d.ts
files). If these declaration files come from an external source like on npm, we would encourage either upgrading your dependencies, forking them, or using a solution like patch-package.
See more on deprecations/behavior changes in 6.0 at #54500.