I have a piece of typescript code that defines an enum in file1.ts:
// file1.ts
export enum Status {
Active = 1,
NotActive = 0
}
In another part of my project, I import the Status enum from file1:
// file2.ts
import {Status} from "./file1";
...
However, when I try to compile the code, I encounter the following error message:
error TS1148: Cannot compile modules unless the '--module' flag is provided.
Consider setting the 'module' compiler option in a 'tsconfig.json' file.
Here is a snippet of my tsconfig file:
{
"compilerOptions": {
"noImplicitAny": true,
"removeComments": true,
"preserveConstEnums": true,
"outFile": "javascript/app.js",
"sourceMap": true,
"target": "es5",
"declaration": false
},
"files": [
"app.ts"
]
}
Instead of exporting modules, I want to create a standalone file containing all the source code to use in the browser. How can I refactor the enum to avoid this compilation error and achieve a self-contained file?
Thanks!