info@enlightsolution.com           01710-318199           9:00AM - 6:00PM

  • Home
  • Services
    • Custom Software Development
    • Web Application
    • Mobile Application
  • Products
    • Enlight Business Solutions
    • Enlight Accounting
    • Enlight HR & Payroll
    • Enlight POS
    • Asset Management System
  • Portfolio
  • Insights
  • About Us
  • Career
  • Contact US

Namespaces in Typescript

Namespaces in Typescript

by Admin / Sunday, 07 July 2019 / Published in JavaScript

Namespaces:

The namespace is used for logical grouping of functionalities. A namespace can include interfaces, classes, functions and variables to support a single or a group of related functionalities.

A namespace can be created using the namespace  keyword followed by the namespace name. All the interfaces, classes etc. can be defined in the curly brackets { }.

Syntax:

How can we use namespace?

In this example, we have a namespace named studentcal in file studentcalc.ts. We want to use the feeCalc function in another program. That’s why export keyword should use before the desire function.

Now we want to use the studentcal namespace as well as feeCalc function to calculate a value in a new program app.ts using the reference just like below code.

If we run this app.ts using the following command we will get an error indicates “can’t find studentcal”.

To solve this problem, we have to combine this two files studentcalc.ts and app.ts. A file  named out.js. will be created if we command this line-

We got a new file named out.js. Then we have to run this out.js and that will solve the problem.

Happy Coding!!!!!

 

 

About Admin

What you can read next

HTTP Module
How to save image and load a picture in A pixel art editor
ECMAScript Modules

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

ENLIGHT SOLUTIONS

Enlight Solutions is working with Leading software development system. We provide out clients nice and fluent software solutions in minimum amount of time.

Quick Links

  • About Us
  • Products
  • Services
  • Portfolio
  • Blog
  • Career

All right reserved.
ENLIGHT SOLUTIONS @ 2019

  • Home
  • contact us
TOP