Reputation: 703
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?
Upvotes: 2
Views: 1271
Reputation: 24555
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.
Upvotes: 1