Skip to content

Visibility of multiple same namespace in a .ts file #6822

Closed
@tianyuanzhonglu

Description

@tianyuanzhonglu

tsc 1.8.0 beta

demo.ts

namespace NS_APP {

class Greeter {
    greeting: string;
    constructor(message: string) {
        this.greeting = message;
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}

}

namespace NS_APP {

class Demo {
    constructor(private greeter: Greeter) {

    }
}   

}

tsc error prompt:
error TS2304: Cannot find name 'Greeter'.
I want Greeter to be private/protected for same namespace, if I use export token, Greeter is public for namespace NS_APP.

demo.ts

namespace NS_APP {

**export** class Greeter {
    greeting: string;
    constructor(message: string) {
        this.greeting = message;
    }
    greet() {
        return "Hello, " + this.greeting;
    }
}

}

namespace NS_APP {

class Demo {
    constructor(private greeter: Greeter) {

    }
}   

}

My question, can Typescript support 'partial' namespace in one or multiple file?

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