I have the following input:
import {onMediaChangeSubscribe} from '../functions/doOnMediaChange'
export class ActionButton extends ElementBase {
mount(){
onMediaChangeSubscribe(this.render)
}
}
The output of typescript 4.3.x is:
doOnMediaChange_1.onMediaChangeSubscribe(this.render);
And typescript 4.4.x do the following:
(0, doOnMediaChange_1.onMediaChangeSubscribe)(this.render);
W̶h̶a̶t̶ ̶t̶h̶e̶ ̶h̶a̶c̶k̶?̶?̶?̶ My question is partially answered here: JavaScript syntax (0, fn)(args), but I would like to clarify.
Why there is such a change in TypeScript?
Minimal reproduction example:
a.ts
export function doTheThing(){}
b.ts
import {doTheThing} from './a'
doTheThing()
b.ts compiles to:
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var a_1 = require("./a");
(0, a_1.doTheThing)();
Used tsconfig.json
:
{
"compilerOptions": {
"module": "commonjs",
"target": "es5",
"sourceMap": true,
"declaration": true,
"strict": true,
"noImplicitAny": false,
"esModuleInterop": true,
"resolveJsonModule": true,
"downlevelIteration": true
},
"exclude": [
"node_modules"
]
}