by
82k 39
0
6
3,603
0
Top 1% !
Popular
Famous
Tagged
Specified
OpenSource
Popularity: 3204th place
Created
Modified Jul 1, 2013

Published on:

LanguageTypeScript
LicenseMIT_X11
MacOS Version10.7.5
OSMac OS X

Create and use of 'Module' in TypeScript

A module in TypeScript is just a syntactic construct to manage namespaces in your application.<br/>
Classes defined inside a <strong>module</strong> need to have the 'export' keyword prefix in order to ensure their visibility outside the module.
Copy Embed Code
<iframe id="embedFrame" style="width:600px; height:300px;"
src="https://www.snip2code.com/Embed/1663/Create-and-use-of--Module--in-TypeScript?startLine=0"></iframe>
Click on the embed code to copy it into your clipboard Width Height
Leave empty to retrieve all the content Start End
// A module is much like a namespace module MyClasses { // Class: note that needs the export keyword in order to be visible from // outside the module export class Product { // Constructor constructor(public name: string, public id: number) { }; // Instance function member public info(): string { return this.name + " " + this.id; }; } } var aProduct = new MyClasses.Product("Samsung TV", 12345 ); $('#prodInfo').html( aProduct.info() );
If you want to be updated about similar snippets, Sign in and follow our Channels

blog comments powered by Disqus