December 2017
Beginner
372 pages
10h 32m
English
TypeScript provides us with the export keyword, which allows us to expose the selected members of our namespace to the outside world. We can just prefix the export keyword on a class, function, interface, or even on a variable inside the namespace and, then, we can access them outside immediately. The export keyword works like a public keyword, which we saw in the preceding chapter.
So, if we modify our preceding example by adding the export keyword to our WebResponseclass, we will then be able to access the class outside, as you can see in the following code snippet:
namespace WebServiceResponse{ export class WebResponse{ getResponse(){ return "Success"; } sendResponse(){ return "200 OK"; } } let localResponse = new WebResponse(); ...Read now
Unlock full access