Skip to content

Confusing documentation on namespaces/internal modules #13774

@maxkoretskyi

Description

@maxkoretskyi

The official TS manual says the following:

It’s important to note that in TypeScript 1.5, the nomenclature has changed. “Internal modules” are now “namespaces”. “External modules” are now simply “modules”

Based on that quote, I was under impression that declare module is no longer used and should be replaced by declare namespace, however I still see module used in different packages. For example, when exploring node_modules\@types\node\index.d.ts I can see that both declare module and declare namespace is used:

declare namespace NodeJS {
    export var Console: {
        prototype: Console;
        new(stdout: WritableStream, stderr?: WritableStream): Console;
    }
...

declare module "buffer" {
    export var INSPECT_MAX_BYTES: number;
    var BuffType: typeof Buffer;
    var SlowBuffType: typeof SlowBuffer;
    export { BuffType as Buffer, SlowBuffType as SlowBuffer };
}

Is it simply a legacy code and declare module "buffer" can be replaced with declare namespace buffer, or there is a difference between them and I should use declare module in my code as well?

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions