Created
August 19, 2015 08:41
-
-
Save Petah/9ed93de155908ba0b496 to your computer and use it in GitHub Desktop.
TypeScript namespaces and require
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path="src/someName.d.ts" /> | |
/// <reference path="src/c1.ts" /> | |
/// <reference path="src/c2.ts" /> | |
/// <reference path="src/app.ts" /> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import someName = require('someName'); | |
var t = new Test(); | |
t.bar(someName()); | |
var t2 = new NS.NSTest(); | |
t2.bar(someName()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Test { | |
public foo: someName; | |
public bar(arg: someName): someName { | |
return someName(); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace NS { | |
export class NSTest { | |
public foo: someName; | |
public bar(arg: someName): someName { | |
return someName(); | |
} | |
} | |
var t = new NSTest(); | |
t.bar(someName()); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'someName' { | |
interface someName { | |
(...args: any[]): someName | |
} | |
var someName:someName; | |
export = someName; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"target": "ES5", | |
"out": "dist/dist.js", | |
"sourceMap": true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment