This question already has an answer here:
I have a tsconfig in my project that specifies a module target of 'amd' but when my file compiles I am getting an output that looks more like CommonJS. Example:
tsconfig:
{
"compilerOptions": {
"module": "amd",
"target": "es5",
"moduleResolution": "node",
"sourceMap": false,
"newLine": "LF",
"baseUrl": ".",
"lib": ["es5", "es2015.promise", "dom"]
}
}
Typescript File:
export function test() {
console.log('Starting Up', '<--------------');
}
Compiled File:
define(["require", "exports"], function (require, exports) {
Object.defineProperty(exports, "__esModule", { value: true });
function test() {
console.log('Starting Up', '<--------------');
}
exports.test = test;
});
Expected Compiled File:
define([], function () {
function test() {
console.log('Starting Up', '<--------------');
}
return { test: test };
});
It's the 'export' object that's throwing me off. This should not be necessary for an AMD module, only a return statement. Is there a way to correct this?
Unfortunately not. That is the shape of TypeScript's AMD output and it is AMD compliant. AMD offers this facility and TypeScript uses it.