2

I am new in TypeScript, I wrote some simple classes and methods but I don't know how to access to them!

I used gulp via browserify, tsify to bundle my .ts files to one file.

Imagine the main class name is library and here is that:

import {something} from "./someWhere";

class libraryClass{
  //Some code here too... 
}


var library = new libraryClass();

var testVar = "TypeScript";

now when I compile and bundle my files to one .js file, what I have inside the code works as expected (such as console.log(s)), but, how can I access my libraryClass class? How can I access the methods inside libraryClass class?!

Accessing the libraryClass does not work, nor testVar

example:

console.log(library)
console.log(testVar)

Both returns

Uncaught ReferenceError: library is not defined Uncaught

ReferenceError: testVar is not defined

Here is my tsconfig.json:

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es5",
    "sourceMap": true,
    "lib": ["dom", "es2015.promise", "es5"]
  },
  "exclude": [
    "node_modules"
  ],
  "include": [
    "src/**/*"
  ]
}
  • https://www.typescriptlang.org/docs/handbook/modules.html ? – zerkms Feb 12 '17 at 21:30
  • @zerkms the problem did not solve, can you help please – TypeScript Learner Feb 12 '17 at 21:58
  • You don't export anything in your code. "the problem did not solve" --- what did you do to solve it? – zerkms Feb 12 '17 at 22:08
  • @zerkms I read some pages on the web and I also used the same configs that the typeScript website said, but still does not work. I just know I should use system module, but still not working and just I get another error on browser which says *System is not defined* – TypeScript Learner Feb 12 '17 at 22:20
  • @TypeScriptLearner I think what you're looking for is `--standalone` parameter https://github.com/substack/browserify-handbook#standalone – martin Feb 13 '17 at 18:57
  • @martin Thank you, I will check this out now – TypeScript Learner Feb 13 '17 at 20:50
  • Possible duplicate of [How to call TypeScript functions out of the .ts files?](http://stackoverflow.com/questions/42234985/how-to-call-typescript-functions-out-of-the-ts-files) – TypeScript Learner Feb 17 '17 at 10:36

0 Answers0