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/**/*"
]
}