Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

206
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda