提交 80026843 编写于 作者: F Fathy Boundjadj 提交者: Devon Govett

Set TypeScript option esModuleInterop to true by default (#971)

上级 e3c90c40
......@@ -88,7 +88,7 @@
"sinon": "^4.2.2",
"sourcemap-validator": "^1.0.6",
"stylus": "^0.54.5",
"typescript": "^2.6.2"
"typescript": "^2.7.0"
},
"scripts": {
"test": "cross-env NODE_ENV=test mocha",
......
......@@ -8,7 +8,11 @@ class TypeScriptAsset extends JSAsset {
let transpilerOptions = {
compilerOptions: {
module: typescript.ModuleKind.CommonJS,
jsx: typescript.JsxEmit.Preserve
jsx: typescript.JsxEmit.Preserve,
// it brings the generated output from TypeScript closer to that generated by Babel
// see https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-7.html
esModuleInterop: true
},
fileName: this.relativeName
};
......
import testModule from './commonjs-module'
export const test = testModule
......@@ -106,4 +106,24 @@ describe('typescript', function() {
let file = fs.readFileSync(__dirname + '/dist/index.js', 'utf8');
assert(file.includes('React.createElement("div"'));
});
it('should use esModuleInterop by default', async function() {
let b = await bundle(
__dirname + '/integration/typescript-interop/index.ts'
);
assertBundleTree(b, {
name: 'index.js',
assets: ['index.ts', 'commonjs-module.js'],
childBundles: [
{
type: 'map'
}
]
});
let output = run(b);
assert.equal(typeof output.test, 'function');
assert.equal(output.test(), 'test passed');
});
});
......@@ -6087,7 +6087,7 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
typescript@^2.6.2:
typescript@^2.7.0:
version "2.7.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.7.2.tgz#2d615a1ef4aee4f574425cdff7026edf81919836"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册