I'm relatively new to typescript and I quite do not understand why after performing tsc Program.ts
and then running
Program.js
in browser it yells at me ReferenceError: exports is not defined
Program.ts
import { TestClass } from './TestClass';
var tc = new TestClass();
console.log(tc.Test("test"));
TestClass.ts
import {Data} from "./Data";
export class TestClass
{
constructor() {}
Test(originalString:string)
{
console.log(Data.Symbols["John"] + " " + originalString);
}
}
Data.ts
export abstract class Data
{
public static Symbols:{[symbol: string] : string} =
{
"John":"a5fq36831v",
}
}
package-lock.json
{
"requires": true,
"lockfileVersion": 1,
"dependencies":
{
"uniq":
{
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/uniq/-/uniq-1.0.1.tgz",
"integrity": "sha1-sxxa6CVIRKOoKBVBzisEuGWnNP8="
}
}
}
I have npm i @types/node
installed
I have seen this thread: Typescript ReferenceError: exports is not defined
but I don't have any tsconfig.json
or babelrc
file.
This trick works partly for me <script>var exports = {};</script>
t
because after that ReferenceError: require is not defined
Is it possible to make it work without installing additional tons of software?
from Exports is not defined ia tsc'ed (js) files
No comments:
Post a Comment