DEV Community

Discussion on: Sometimes the Typescript CLI seems strangely opaque

Collapse
bugmagnet profile image
Bruce Axtens Author

To answer my own question, based on the response on StackOverflow, one needs to create a file-specific version of the tsconfig.json and use that when compiling the single file.

So here's the original tsconfig.json:

{
  "compileOnSave": true,
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "target": "ES3",
    "lib": ["ESNext"],
    "strict": false,
    "moduleResolution": "node",
    "module": "system",
    "types": [".\\types"],
    "removeComments": true,
  },
  "include": ["*.ts"]
}
Enter fullscreen mode Exit fullscreen mode

I now have a separate BOML.tsconfig file (BOML is the name of the single target in this case) which is:

{
  "compileOnSave": true,
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "target": "ES3",
    "lib": ["ESNext"],
    "strict": false,
    "moduleResolution": "node",
    "module": "system",
    "types": [".\\types"],
    "removeComments": true,
    "outFile": "BOML.RR"
  },
  "files": ["BOML.ts"]
}
Enter fullscreen mode Exit fullscreen mode

To compile: npx tsc -p boml.tsconfig and I get a nice boml.rr at the end