Skip to content

Instantly share code, notes, and snippets.

@ivankisyov
Created December 26, 2018 10:13
Show Gist options
  • Save ivankisyov/40ab7dab99d810f0442b425259ea4a83 to your computer and use it in GitHub Desktop.
Save ivankisyov/40ab7dab99d810f0442b425259ea4a83 to your computer and use it in GitHub Desktop.
Namespaces in TypeScript

Namespaces in TypeScript

appInfo.ts

namespace AppInfo {
  const version: string = "1.0.0";

  export function getVersion() {
    return version;
  }
}

app.ts

/// <reference path="appInfo.ts" />

const version = AppInfo.getVersion();
console.log(version);

compile command:

tsc app.ts --outFile app.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment