Export and Default Exports

TypeScript Export - What's an export in TypeScript?

Why using export in TypeScript?

Export - Exporting a declaration
Any variable, function, class or interface can be exported by using the export keyword. After using export keyword, you can access your variable, function, class or interface to outside the module.

Examples as–
module System.modules {
    //this function can be accessed from outside the module becaues using export.
    export function addNumbers(a: number, b: number): number {
        return a + b;
    }

    // this class can be accessed from outside the module becaues using export.
    export class ExportedClass {
        public subNumbers(a: number, b: number): number {
            return a - b;
        }
    }
}

And

namespace System.namespaces {
    //this function can be accessed from outside the module becaues using export.
    export function addNumbers(a: number, b: number): number {
        return a + b;
    }

    // this class can be accessed from outside the module becaues using export.
    export class ExportedClass {
        public subNumbers(a: number, b: number): number {
            return a - b;
        }
    }
}

Stayed Informed – Learn Angular 2 with TypeScript

I hope you are enjoying with this post! Please share with you friends. Thank you!!
ANIL SINGH

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..

My Tech Blog - https://www.code-sample.com/
My Books - Book 1 and Book 2

www.code-sample.com/. Powered by Blogger.
^