Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2998,7 +2998,7 @@ namespace ts {
// A ClassDeclaration is ES6 syntax.
transformFlags = subtreeFlags | TransformFlags.AssertES2015;

// A class with a parameter property assignment, property initializer, or decorator is
// A class with a parameter property assignment, property initializer, computed property name, or decorator is
// TypeScript syntax.
// An exported declaration may be TypeScript syntax, but is handled by the visitor
// for a namespace declaration.
Expand Down Expand Up @@ -3168,9 +3168,9 @@ namespace ts {
// A PropertyDeclaration is TypeScript syntax.
let transformFlags = subtreeFlags | TransformFlags.AssertTypeScript;

// If the PropertyDeclaration has an initializer, we need to inform its ancestor
// If the PropertyDeclaration has an initializer or a computed name, we need to inform its ancestor
// so that it handle the transformation.
if (node.initializer) {
if (node.initializer || isComputedPropertyName(node.name)) {
transformFlags |= TransformFlags.ContainsPropertyInitializer;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//// [computedPropertiesTransformedInOtherwiseNonTSClasses.ts]
namespace NS {
export const x = Symbol();

class NotTransformed {
[NS.x]: number;
}
}


//// [computedPropertiesTransformedInOtherwiseNonTSClasses.js]
var NS;
(function (NS) {
NS.x = Symbol();
var NotTransformed = /** @class */ (function () {
function NotTransformed() {
}
return NotTransformed;
}());
NS.x;
})(NS || (NS = {}));
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== tests/cases/compiler/computedPropertiesTransformedInOtherwiseNonTSClasses.ts ===
namespace NS {
>NS : Symbol(NS, Decl(computedPropertiesTransformedInOtherwiseNonTSClasses.ts, 0, 0))

export const x = Symbol();
>x : Symbol(x, Decl(computedPropertiesTransformedInOtherwiseNonTSClasses.ts, 1, 16))
>Symbol : Symbol(Symbol, Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --), Decl(lib.es2015.symbol.d.ts, --, --))

class NotTransformed {
>NotTransformed : Symbol(NotTransformed, Decl(computedPropertiesTransformedInOtherwiseNonTSClasses.ts, 1, 30))

[NS.x]: number;
>[NS.x] : Symbol(NotTransformed[NS.x], Decl(computedPropertiesTransformedInOtherwiseNonTSClasses.ts, 3, 26))
>NS.x : Symbol(x, Decl(computedPropertiesTransformedInOtherwiseNonTSClasses.ts, 1, 16))
>NS : Symbol(NS, Decl(computedPropertiesTransformedInOtherwiseNonTSClasses.ts, 0, 0))
>x : Symbol(x, Decl(computedPropertiesTransformedInOtherwiseNonTSClasses.ts, 1, 16))
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
=== tests/cases/compiler/computedPropertiesTransformedInOtherwiseNonTSClasses.ts ===
namespace NS {
>NS : typeof NS

export const x = Symbol();
>x : unique symbol
>Symbol() : unique symbol
>Symbol : SymbolConstructor

class NotTransformed {
>NotTransformed : NotTransformed

[NS.x]: number;
>[NS.x] : number
>NS.x : unique symbol
>NS : typeof NS
>x : unique symbol
}
}

1 change: 1 addition & 0 deletions tests/baselines/reference/indexSignatureWithInitializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ var C = /** @class */ (function () {
}
return C;
}());
x = 0;
1 change: 1 addition & 0 deletions tests/baselines/reference/uniqueSymbols.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ Math.random() * 2 ? N["s"] : "a";
});
class C1 {
}
N.s, N.s;
const o3 = {
method1() {
return s; // return type should not widen due to contextual type
Expand Down
1 change: 1 addition & 0 deletions tests/baselines/reference/uniqueSymbolsDeclarations.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ Math.random() * 2 ? N["s"] : "a";
});
class C1 {
}
N.s, N.s;
const o4 = {
method1() {
return s; // return type should not widen due to contextual type
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// @lib: es6
namespace NS {
export const x = Symbol();

class NotTransformed {
[NS.x]: number;
}
}