2

this is my client class:

namespace Core {
    export class Client {}
}

and I create a new object like below:

let client = new Core.Client();

but I get this error:

/dist/index.js:10
    let client = new Core.Client()
                 ^

ReferenceError: Core is not defined
    at Namespace.<anonymous> (/dist/index.js:10:18)
    at Namespace.emit (events.js:314:20)
    at Namespace.emit (/node_modules/socket.io/lib/namespace.js:213:10)
    at /node_modules/socket.io/lib/namespace.js:181:14
    at processTicksAndRejections (internal/process/task_queues.js:79:11)

what is the problem?

1 Answer 1

1

You need to reference your namespace in your index.ts. So if Client is in a file called core.ts you need to do:

/// <reference path="core.ts" />
let client = new Core.Client();

And you need to export your namespace:

export namespace Core {
    export class Client {}
}

See the handbook for more information.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.