use modulekind to check if initializer for shorthand property assignment should be emitted
This commit is contained in:
parent
a4d10bd777
commit
6f08e89455
|
@ -2461,7 +2461,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||||
// let obj = { y };
|
// let obj = { y };
|
||||||
// }
|
// }
|
||||||
// Here we need to emit obj = { y : m.y } regardless of the output target.
|
// Here we need to emit obj = { y : m.y } regardless of the output target.
|
||||||
if (languageVersion < ScriptTarget.ES6 || isNamespaceExportReference(node.name)) {
|
if (modulekind !== ModuleKind.ES6 || isNamespaceExportReference(node.name)) {
|
||||||
// Emit identifier as an identifier
|
// Emit identifier as an identifier
|
||||||
write(": ");
|
write(": ");
|
||||||
emit(node.name);
|
emit(node.name);
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
tests/cases/compiler/test.ts(2,19): error TS2307: Cannot find module './foo2'.
|
||||||
|
tests/cases/compiler/test.ts(6,1): error TS2304: Cannot find name 'console'.
|
||||||
|
tests/cases/compiler/test.ts(7,1): error TS2304: Cannot find name 'console'.
|
||||||
|
|
||||||
|
|
||||||
|
==== tests/cases/compiler/foo1.ts (0 errors) ====
|
||||||
|
|
||||||
|
export var x = 1;
|
||||||
|
|
||||||
|
==== tests/cases/compiler/test.ts (3 errors) ====
|
||||||
|
import {x} from './foo1';
|
||||||
|
import {foo} from './foo2';
|
||||||
|
~~~~~~~~
|
||||||
|
!!! error TS2307: Cannot find module './foo2'.
|
||||||
|
|
||||||
|
const test = { x, foo };
|
||||||
|
|
||||||
|
console.log(x);
|
||||||
|
~~~~~~~
|
||||||
|
!!! error TS2304: Cannot find name 'console'.
|
||||||
|
console.log(foo);
|
||||||
|
~~~~~~~
|
||||||
|
!!! error TS2304: Cannot find name 'console'.
|
|
@ -0,0 +1,23 @@
|
||||||
|
//// [tests/cases/compiler/shorthandPropertyAssignmentInES6Module.ts] ////
|
||||||
|
|
||||||
|
//// [foo1.ts]
|
||||||
|
|
||||||
|
export var x = 1;
|
||||||
|
|
||||||
|
//// [test.ts]
|
||||||
|
import {x} from './foo1';
|
||||||
|
import {foo} from './foo2';
|
||||||
|
|
||||||
|
const test = { x, foo };
|
||||||
|
|
||||||
|
console.log(x);
|
||||||
|
console.log(foo);
|
||||||
|
|
||||||
|
//// [foo1.js]
|
||||||
|
exports.x = 1;
|
||||||
|
//// [test.js]
|
||||||
|
var foo1_1 = require('./foo1');
|
||||||
|
var foo2_1 = require('./foo2');
|
||||||
|
const test = { x: foo1_1.x, foo: foo2_1.foo };
|
||||||
|
console.log(foo1_1.x);
|
||||||
|
console.log(foo2_1.foo);
|
|
@ -0,0 +1,14 @@
|
||||||
|
// @target: ES6
|
||||||
|
// @module: commonjs
|
||||||
|
|
||||||
|
// @filename: foo1.ts
|
||||||
|
export var x = 1;
|
||||||
|
|
||||||
|
// @filename: test.ts
|
||||||
|
import {x} from './foo1';
|
||||||
|
import {foo} from './foo2';
|
||||||
|
|
||||||
|
const test = { x, foo };
|
||||||
|
|
||||||
|
console.log(x);
|
||||||
|
console.log(foo);
|
Loading…
Reference in a new issue