Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

204
Views
Why was my TypeScript function compiled using comma operator? How to disable that?

I have a class Helper with a function getInfo defined like this...

// Helper package

function Helper() {
    this.loaded = true;
   .....
}

Helper.prototype.getInfo = function(id) {
    if (!this.loaded) { loadData.apply(this) }
    .....
};

I imported the Helper package and use it like this

import {getInfo} from "helper"
...
const CONFIG: Config[] = [
 {name: "foo", info: [getInfo("foo")]},
 {name: "bar", info: [getInfo("bar")]},
]
...

In v3.6.5, it was compiled like this...

const helper_1 = require("helper");
...
const CONFIG: Config[] = [
 {name: "foo", info: [helper_1.getInfo("foo")]},
 {name: "bar", info: [helper_1.getInfo("bar")]},
]
...

In v4.x, it was compiled like this...

const helper_1 = require("helper");
...
const CONFIG: Config[] = [
 {name: "foo", info: [(0,helper_1.getInfo)("foo")]},
 {name: "bar", info: [(0,helper_1.getInfo)("bar")]},
]
...

Since it's using a comma separator, I got an undefined this.

Here's my tsconfig:

{
  "compilerOptions": {
    "target":"ES2018",
    "module": "commonjs",
    "lib": ["esnext", "es2016", "es2017.object", "es2017.string"],
    "declaration": true,
    "outDir": "./dist/lib",
    "declarationDir": "./dist/types",
    "strict": true,
    "noImplicitAny": true,
    "strictNullChecks": true,
    "noImplicitThis": true,
    "alwaysStrict": true,
    "noUnusedLocals": false,
    "noUnusedParameters": false,
    "noImplicitReturns": true,
    "noFallthroughCasesInSwitch": false,
    "inlineSourceMap": true,
    "inlineSources": true,
    "experimentalDecorators": true,
    "strictPropertyInitialization":false,
    "typeRoots": ["./node_modules/@types"]
  },
  "exclude": ["build","node_modules", "dist"]
}

How do I stop TypeScript from compiling using comma operator?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!