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?