diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index 5bf678f5436bf..4cae7d0749cc2 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2665,15 +2665,17 @@ module ts { } function emitSuper(node: Node) { - let flags = resolver.getNodeCheckFlags(node); - if (flags & NodeCheckFlags.SuperInstance) { - write("_super.prototype"); - } - else if (flags & NodeCheckFlags.SuperStatic) { - write("_super"); + if (languageVersion >= ScriptTarget.ES6) { + write("super"); } else { - write("super"); + var flags = resolver.getNodeCheckFlags(node); + if (flags & NodeCheckFlags.SuperInstance) { + write("_super.prototype"); + } + else { + write("_super"); + } } } @@ -3222,14 +3224,14 @@ module ts { } let superCall = false; if (node.expression.kind === SyntaxKind.SuperKeyword) { - write("_super"); + emitSuper(node.expression); superCall = true; } else { emit(node.expression); superCall = node.expression.kind === SyntaxKind.PropertyAccessExpression && (node.expression).expression.kind === SyntaxKind.SuperKeyword; } - if (superCall) { + if (superCall && languageVersion < ScriptTarget.ES6) { write(".call("); emitThis(node.expression); if (node.arguments.length) { @@ -4627,7 +4629,7 @@ module ts { }); } - function emitMemberFunctions(node: ClassDeclaration) { + function emitMemberFunctionsForES5AndLower(node: ClassDeclaration) { forEach(node.members, member => { if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) { if (!(member).body) { @@ -4645,7 +4647,6 @@ module ts { emitMemberAccessForPropertyName((member).name); emitEnd((member).name); write(" = "); - // TODO (drosen): Should we performing emitStart twice on emitStart(member)? emitStart(member); emitFunctionDeclaration(member); emitEnd(member); @@ -4665,7 +4666,6 @@ module ts { write(".prototype"); } write(", "); - // TODO: Shouldn't emitStart on name occur *here*? emitExpressionForPropertyName((member).name); emitEnd((member).name); write(", {"); @@ -4705,7 +4705,194 @@ module ts { }); } - function emitClassDeclaration(node: ClassDeclaration) { + function emitMemberFunctionsForES6AndHigher(node: ClassDeclaration) { + for (let member of node.members) { + if ((member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature) && !(member).body) { + emitPinnedOrTripleSlashComments(member); + } + else if (member.kind === SyntaxKind.MethodDeclaration || node.kind === SyntaxKind.MethodSignature || member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) { + writeLine(); + emitLeadingComments(member); + emitStart(member); + if (member.flags & NodeFlags.Static) { + write("static "); + } + + if (member.kind === SyntaxKind.GetAccessor) { + write("get "); + } + else if (member.kind === SyntaxKind.SetAccessor) { + write("set "); + } + emit((member).name); + emitSignatureAndBody(member); + emitEnd(member); + emitTrailingComments(member); + } + } + } + + function emitConstructor(node: ClassDeclaration, baseTypeNode: TypeReferenceNode) { + let saveTempCount = tempCount; + let saveTempVariables = tempVariables; + let saveTempParameters = tempParameters; + tempCount = 0; + tempVariables = undefined; + tempParameters = undefined; + + let popFrame = enterNameScope(); + // Check if we have property assignment inside class declaration. + // If there is property assignment, we need to emit constructor whether users define it or not + // If there is no property assignment, we can omit constructor if users do not define it + let hasInstancePropertyWithInitializer = false; + + // Emit the constructor overload pinned comments + forEach(node.members, member => { + if (member.kind === SyntaxKind.Constructor && !(member).body) { + emitPinnedOrTripleSlashComments(member); + } + // Check if there is any non-static property assignment + if (member.kind === SyntaxKind.PropertyDeclaration && (member).initializer && (member.flags & NodeFlags.Static) === 0) { + hasInstancePropertyWithInitializer = true; + } + }); + + let ctor = getFirstConstructorWithBody(node); + + // For target ES6 and above, if there is no user-defined constructor and there is no property assignment + // do not emit constructor in class declaration. + if (languageVersion >= ScriptTarget.ES6 && !ctor && !hasInstancePropertyWithInitializer) { + return; + } + + if (ctor) { + emitLeadingComments(ctor); + } + emitStart(ctor || node); + + if (languageVersion < ScriptTarget.ES6) { + write("function "); + emitDeclarationName(node); + emitSignatureParameters(ctor); + } + else { + write("constructor"); + if (ctor) { + emitSignatureParameters(ctor); + } + else { + // Based on EcmaScript6 section 14.5.14: Runtime Semantics: ClassDefinitionEvaluation. + // If constructor is empty, then, + // If ClassHeritageopt is present, then + // Let constructor be the result of parsing the String "constructor(... args){ super (...args);}" using the syntactic grammar with the goal symbol MethodDefinition. + // Else, + // Let constructor be the result of parsing the String "constructor( ){ }" using the syntactic grammar with the goal symbol MethodDefinition + if (baseTypeNode) { + write("(...args)"); + } + else { + write("()"); + } + } + } + + write(" {"); + scopeEmitStart(node, "constructor"); + increaseIndent(); + if (ctor) { + emitDetachedComments(ctor.body.statements); + } + emitCaptureThisForNodeIfNecessary(node); + if (ctor) { + emitDefaultValueAssignments(ctor); + emitRestParameter(ctor); + if (baseTypeNode) { + var superCall = findInitialSuperCall(ctor); + if (superCall) { + writeLine(); + emit(superCall); + } + } + emitParameterPropertyAssignments(ctor); + } + else { + if (baseTypeNode) { + writeLine(); + emitStart(baseTypeNode); + if (languageVersion < ScriptTarget.ES6) { + write("_super.apply(this, arguments);"); + } + else { + write("super(...args);"); + } + emitEnd(baseTypeNode); + } + } + emitMemberAssignments(node, /*staticFlag*/0); + if (ctor) { + var statements: Node[] = (ctor.body).statements; + if (superCall) { + statements = statements.slice(1); + } + emitLines(statements); + } + emitTempDeclarations(/*newLine*/ true); + writeLine(); + if (ctor) { + emitLeadingCommentsOfPosition((ctor.body).statements.end); + } + decreaseIndent(); + emitToken(SyntaxKind.CloseBraceToken, ctor ? (ctor.body).statements.end : node.members.end); + scopeEmitEnd(); + emitEnd(ctor || node); + if (ctor) { + emitTrailingComments(ctor); + } + + exitNameScope(popFrame); + + tempCount = saveTempCount; + tempVariables = saveTempVariables; + tempParameters = saveTempParameters; + } + + function emitClassDeclarationForES6AndHigher(node: ClassDeclaration) { + if (node.flags & NodeFlags.Export) { + write("export "); + + if (node.flags & NodeFlags.Default) { + write("default "); + } + } + + write("class "); + emitDeclarationName(node); + var baseTypeNode = getClassBaseTypeNode(node); + if (baseTypeNode) { + write(" extends "); + emit(baseTypeNode.typeName); + } + write(" {"); + increaseIndent(); + scopeEmitStart(node); + writeLine(); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES6AndHigher(node); + decreaseIndent(); + writeLine(); + emitToken(SyntaxKind.CloseBraceToken, node.members.end); + scopeEmitEnd(); + + // Emit static property assignment. Because classDeclaration is lexically evaluated, + // it is safe to emit static property assignment after classDeclaration + // From ES6 specification: + // HasLexicalDeclaration (N) : Determines if the argument identifier has a binding in this environment record that was created using + // a lexical declaration such as a LexicalDeclaration or a ClassDeclaration. + writeLine(); + emitMemberAssignments(node, NodeFlags.Static); + } + + function emitClassDeclarationBelowES6(node: ClassDeclaration) { write("var "); emitDeclarationName(node); write(" = (function ("); @@ -4725,8 +4912,8 @@ module ts { emitEnd(baseTypeNode); } writeLine(); - emitConstructorOfClass(); - emitMemberFunctions(node); + emitConstructor(node, baseTypeNode); + emitMemberFunctionsForES5AndLower(node); emitMemberAssignments(node, NodeFlags.Static); writeLine(); emitToken(SyntaxKind.CloseBraceToken, node.members.end, () => { @@ -4757,85 +4944,6 @@ module ts { if (languageVersion < ScriptTarget.ES6 && node.parent === currentSourceFile && node.name) { emitExportMemberAssignments(node.name); } - - function emitConstructorOfClass() { - let saveTempCount = tempCount; - let saveTempVariables = tempVariables; - let saveTempParameters = tempParameters; - tempCount = 0; - tempVariables = undefined; - tempParameters = undefined; - - let popFrame = enterNameScope(); - - // Emit the constructor overload pinned comments - forEach(node.members, member => { - if (member.kind === SyntaxKind.Constructor && !(member).body) { - emitPinnedOrTripleSlashComments(member); - } - }); - - let ctor = getFirstConstructorWithBody(node); - if (ctor) { - emitLeadingComments(ctor); - } - emitStart(ctor || node); - write("function "); - emitDeclarationName(node); - emitSignatureParameters(ctor); - write(" {"); - scopeEmitStart(node, "constructor"); - increaseIndent(); - if (ctor) { - emitDetachedComments((ctor.body).statements); - } - emitCaptureThisForNodeIfNecessary(node); - let superCall: ExpressionStatement; - if (ctor) { - emitDefaultValueAssignments(ctor); - emitRestParameter(ctor); - if (baseTypeNode) { - superCall = findInitialSuperCall(ctor); - if (superCall) { - writeLine(); - emit(superCall); - } - } - emitParameterPropertyAssignments(ctor); - } - else { - if (baseTypeNode) { - writeLine(); - emitStart(baseTypeNode); - write("_super.apply(this, arguments);"); - emitEnd(baseTypeNode); - } - } - emitMemberAssignments(node, /*nonstatic*/0); - if (ctor) { - let statements: Node[] = (ctor.body).statements; - if (superCall) statements = statements.slice(1); - emitLines(statements); - } - emitTempDeclarations(/*newLine*/ true); - writeLine(); - if (ctor) { - emitLeadingCommentsOfPosition((ctor.body).statements.end); - } - decreaseIndent(); - emitToken(SyntaxKind.CloseBraceToken, ctor ? (ctor.body).statements.end : node.members.end); - scopeEmitEnd(); - emitEnd(ctor || node); - if (ctor) { - emitTrailingComments(ctor); - } - - exitNameScope(popFrame); - - tempCount = saveTempCount; - tempVariables = saveTempVariables; - tempParameters = saveTempParameters; - } } function emitInterfaceDeclaration(node: InterfaceDeclaration) { @@ -5321,8 +5429,10 @@ module ts { emitDetachedComments(node); // emit prologue directives prior to __extends - let startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); - if (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends) { + var startIndex = emitDirectivePrologues(node.statements, /*startWithNewLine*/ false); + // Only Emit __extends function when target ES5. + // For target ES6 and above, we can emit classDeclaration as if. + if ((languageVersion < ScriptTarget.ES6) && (!extendsEmitted && resolver.getNodeCheckFlags(node) & NodeCheckFlags.EmitExtends)) { writeLine(); write("var __extends = this.__extends || function (d, b) {"); increaseIndent(); @@ -5554,7 +5664,7 @@ module ts { case SyntaxKind.VariableDeclaration: return emitVariableDeclaration(node); case SyntaxKind.ClassDeclaration: - return emitClassDeclaration(node); + return languageVersion < ScriptTarget.ES6 ? emitClassDeclarationBelowES6(node) : emitClassDeclarationForES6AndHigher(node); case SyntaxKind.InterfaceDeclaration: return emitInterfaceDeclaration(node); case SyntaxKind.EnumDeclaration: diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index 27f550778c19d..117b9c6937896 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -613,7 +613,7 @@ module ts { // change the token touching it, we actually need to look back *at least* one token so // that the prior token sees that change. let maxLookahead = 1; - + let start = changeRange.span.start; // the first iteration aligns us with the change start. subsequent iteration move us to @@ -831,7 +831,7 @@ module ts { // will immediately bail out of walking any subtrees when we can see that their parents // are already correct. let result = parseSourceFile(sourceFile.fileName, newText, sourceFile.languageVersion, syntaxCursor, /* setParentNode */ true) - + return result; } @@ -1986,7 +1986,7 @@ module ts { // // let v = new List < A, B >() // - // then we have a problem. "v = new List"); let node = createNode(SyntaxKind.ArrowFunction, identifier.pos); - + let parameter = createNode(SyntaxKind.Parameter, identifier.pos); - parameter.name = identifier; + parameter.name = identifier; finishNode(parameter); node.parameters = >[parameter]; @@ -3140,8 +3140,8 @@ module ts { function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction { let node = createNode(SyntaxKind.ArrowFunction); - // Arrow functions are never generators. - // + // Arrow functions are never generators. + // // If we're speculatively parsing a signature for a parenthesized arrow function, then // we have to have a complete parameter list. Otherwise we might see something like // a => (b => c) @@ -3206,7 +3206,7 @@ module ts { // Note: we explicitly 'allowIn' in the whenTrue part of the condition expression, and // we do not that for the 'whenFalse' part. let node = createNode(SyntaxKind.ConditionalExpression, leftOperand.pos); - node.condition = leftOperand; + node.condition = leftOperand; node.questionToken = questionToken; node.whenTrue = allowInAnd(parseAssignmentExpressionOrHigher); node.colonToken = parseExpectedToken(SyntaxKind.ColonToken, /*reportAtCurrentPosition:*/ false, @@ -4526,7 +4526,13 @@ module ts { } function parseClassDeclaration(fullStart: number, modifiers: ModifiersArray): ClassDeclaration { - let node = createNode(SyntaxKind.ClassDeclaration, fullStart); + // In ES6 specification, All parts of a ClassDeclaration or a ClassExpression are strict mode code + let savedStrictModeContext = inStrictModeContext(); + if (languageVersion >= ScriptTarget.ES6) { + setStrictModeContext(true); + } + + var node = createNode(SyntaxKind.ClassDeclaration, fullStart); setModifiers(node, modifiers); parseExpected(SyntaxKind.ClassKeyword); node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier(); @@ -4546,7 +4552,10 @@ module ts { else { node.members = createMissingList(); } - return finishNode(node); + + var finishedNode = finishNode(node); + setStrictModeContext(savedStrictModeContext); + return finishedNode; } function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray { @@ -4774,7 +4783,7 @@ module ts { // walker. let result = parseExpression(); // Ensure the string being required is in our 'identifier' table. This will ensure - // that features like 'find refs' will look inside this file when search for its name. + // that features like 'find refs' will look inside this file when search for its name. if (result.kind === SyntaxKind.StringLiteral) { internIdentifier((result).text); } diff --git a/tests/baselines/reference/callWithSpreadES6.js b/tests/baselines/reference/callWithSpreadES6.js index 0becb4c6e3e0d..d1589d7f6fad1 100644 --- a/tests/baselines/reference/callWithSpreadES6.js +++ b/tests/baselines/reference/callWithSpreadES6.js @@ -55,12 +55,6 @@ var c = new C(1, 2, ...a); //// [callWithSpreadES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; function foo(x, y, ...z) { } var a; @@ -84,26 +78,23 @@ xa[1].foo(...[ 2, "abc" ]); -var C = (function () { - function C(x, y, ...z) { +class C { + constructor(x, y, ...z) { this.foo(x, y); this.foo(x, y, ...z); } - C.prototype.foo = function (x, y, ...z) { - }; - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.call(this, 1, 2); - _super.call(this, 1, 2, ...a); + foo(x, y, ...z) { } - D.prototype.foo = function () { - _super.prototype.foo.call(this, 1, 2); - _super.prototype.foo.call(this, 1, 2, ...a); - }; - return D; -})(C); +} +class D extends C { + constructor() { + super(1, 2); + super(1, 2, ...a); + } + foo() { + super.foo(1, 2); + super.foo(1, 2, ...a); + } +} // Only supported in when target is ES6 var c = new C(1, 2, ...a); diff --git a/tests/baselines/reference/computedPropertyNames12_ES6.js b/tests/baselines/reference/computedPropertyNames12_ES6.js index 5ab6e4c09b312..fd6ccb6e4860f 100644 --- a/tests/baselines/reference/computedPropertyNames12_ES6.js +++ b/tests/baselines/reference/computedPropertyNames12_ES6.js @@ -20,12 +20,11 @@ class C { var s; var n; var a; -var C = (function () { - function C() { +class C { + constructor() { this[n] = n; this[s + n] = 2; this[`hello bye`] = 0; } - C[`hello ${a} bye`] = 0; - return C; -})(); +} +C[`hello ${a} bye`] = 0; diff --git a/tests/baselines/reference/computedPropertyNames13_ES6.js b/tests/baselines/reference/computedPropertyNames13_ES6.js index 07aa1673aba27..18d81fcec59e4 100644 --- a/tests/baselines/reference/computedPropertyNames13_ES6.js +++ b/tests/baselines/reference/computedPropertyNames13_ES6.js @@ -20,30 +20,27 @@ class C { var s; var n; var a; -var C = (function () { - function C() { - } - C.prototype[s] = function () { - }; - C.prototype[n] = function () { - }; - C[s + s] = function () { - }; - C.prototype[s + n] = function () { - }; - C.prototype[+s] = function () { - }; - C[""] = function () { - }; - C.prototype[0] = function () { - }; - C.prototype[a] = function () { - }; - C[true] = function () { - }; - C.prototype[`hello bye`] = function () { - }; - C[`hello ${a} bye`] = function () { - }; - return C; -})(); +class C { + [s]() { + } + [n]() { + } + static [s + s]() { + } + [s + n]() { + } + [+s]() { + } + static [""]() { + } + [0]() { + } + [a]() { + } + static [true]() { + } + [`hello bye`]() { + } + static [`hello ${a} bye`]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames14_ES6.js b/tests/baselines/reference/computedPropertyNames14_ES6.js index 7a58ad9a80a19..b1b2a9bf28542 100644 --- a/tests/baselines/reference/computedPropertyNames14_ES6.js +++ b/tests/baselines/reference/computedPropertyNames14_ES6.js @@ -11,20 +11,17 @@ class C { //// [computedPropertyNames14_ES6.js] var b; -var C = (function () { - function C() { +class C { + [b]() { } - C.prototype[b] = function () { - }; - C[true] = function () { - }; - C.prototype[[]] = function () { - }; - C[{}] = function () { - }; - C.prototype[undefined] = function () { - }; - C[null] = function () { - }; - return C; -})(); + static [true]() { + } + [[]]() { + } + static [{}]() { + } + [undefined]() { + } + static [null]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames15_ES6.js b/tests/baselines/reference/computedPropertyNames15_ES6.js index 70c2e7b451c3a..1a9141ab13d74 100644 --- a/tests/baselines/reference/computedPropertyNames15_ES6.js +++ b/tests/baselines/reference/computedPropertyNames15_ES6.js @@ -12,14 +12,11 @@ class C { var p1; var p2; var p3; -var C = (function () { - function C() { +class C { + [p1]() { } - C.prototype[p1] = function () { - }; - C.prototype[p2] = function () { - }; - C.prototype[p3] = function () { - }; - return C; -})(); + [p2]() { + } + [p3]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames16_ES6.js b/tests/baselines/reference/computedPropertyNames16_ES6.js index 90f15f6cf2e2e..96e175976da1e 100644 --- a/tests/baselines/reference/computedPropertyNames16_ES6.js +++ b/tests/baselines/reference/computedPropertyNames16_ES6.js @@ -20,80 +20,33 @@ class C { var s; var n; var a; -var C = (function () { - function C() { +class C { + get [s]() { + return 0; } - Object.defineProperty(C.prototype, s, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, n, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, s + s, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, s + n, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, +s, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, "", { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, 0, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, a, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, true, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, `hello bye`, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, `hello ${a} bye`, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + set [n](v) { + } + static get [s + s]() { + return 0; + } + set [s + n](v) { + } + get [+s]() { + return 0; + } + static set [""](v) { + } + get [0]() { + return 0; + } + set [a](v) { + } + static get [true]() { + return 0; + } + set [`hello bye`](v) { + } + get [`hello ${a} bye`]() { + return 0; + } +} diff --git a/tests/baselines/reference/computedPropertyNames17_ES6.js b/tests/baselines/reference/computedPropertyNames17_ES6.js index e9b19202e088a..a181a61004eda 100644 --- a/tests/baselines/reference/computedPropertyNames17_ES6.js +++ b/tests/baselines/reference/computedPropertyNames17_ES6.js @@ -11,47 +11,20 @@ class C { //// [computedPropertyNames17_ES6.js] var b; -var C = (function () { - function C() { +class C { + get [b]() { + return 0; } - Object.defineProperty(C.prototype, b, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, true, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, [], { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, {}, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, undefined, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, null, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + static set [true](v) { + } + get [[]]() { + return 0; + } + set [{}](v) { + } + static get [undefined]() { + return 0; + } + set [null](v) { + } +} diff --git a/tests/baselines/reference/computedPropertyNames21_ES6.js b/tests/baselines/reference/computedPropertyNames21_ES6.js index f51f6faed2424..c5f6b4e22b199 100644 --- a/tests/baselines/reference/computedPropertyNames21_ES6.js +++ b/tests/baselines/reference/computedPropertyNames21_ES6.js @@ -7,13 +7,10 @@ class C { } //// [computedPropertyNames21_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { return 0; - }; - C.prototype[this.bar()] = function () { - }; - return C; -})(); + } + [this.bar()]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames22_ES6.js b/tests/baselines/reference/computedPropertyNames22_ES6.js index 9872605c20ed0..c88ceb6bc8f53 100644 --- a/tests/baselines/reference/computedPropertyNames22_ES6.js +++ b/tests/baselines/reference/computedPropertyNames22_ES6.js @@ -9,15 +9,12 @@ class C { } //// [computedPropertyNames22_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { var obj = { [this.bar()]() { } }; return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames23_ES6.js b/tests/baselines/reference/computedPropertyNames23_ES6.js index f5687952b88da..0bae1abdad2c1 100644 --- a/tests/baselines/reference/computedPropertyNames23_ES6.js +++ b/tests/baselines/reference/computedPropertyNames23_ES6.js @@ -9,15 +9,12 @@ class C { } //// [computedPropertyNames23_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { return 0; - }; - C.prototype[{ + } + [{ [this.bar()]: 1 - }[0]] = function () { - }; - return C; -})(); + }[0]]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt index a1290e06956cb..121b39450a61d 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames24_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(9,6): error TS2466: 'super' cannot be referenced in a computed property name. +tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(7,6): error TS2466: 'super' cannot be referenced in a computed property name. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts (1 errors) ==== @@ -8,8 +8,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts(9, } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [super.bar()]() { } ~~~~~ !!! error TS2466: 'super' cannot be referenced in a computed property name. diff --git a/tests/baselines/reference/computedPropertyNames24_ES5.js b/tests/baselines/reference/computedPropertyNames24_ES5.js index d24f406c1adb1..cea5240003b2e 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES5.js +++ b/tests/baselines/reference/computedPropertyNames24_ES5.js @@ -5,8 +5,6 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [super.bar()]() { } } @@ -30,9 +28,7 @@ var C = (function (_super) { function C() { _super.apply(this, arguments); } - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. - C.prototype[super.bar.call(this)] = function () { + C.prototype[_super.bar.call(this)] = function () { }; return C; })(Base); diff --git a/tests/baselines/reference/computedPropertyNames24_ES6.js b/tests/baselines/reference/computedPropertyNames24_ES6.js index 12aef63396342..8d33db10f71ba 100644 --- a/tests/baselines/reference/computedPropertyNames24_ES6.js +++ b/tests/baselines/reference/computedPropertyNames24_ES6.js @@ -11,28 +11,14 @@ class C extends Base { } //// [computedPropertyNames24_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } +} +class C extends Base { // Gets emitted as super, not _super, which is consistent with // use of super in static properties initializers. - C.prototype[super.bar.call(this)] = function () { - }; - return C; -})(Base); + [super.bar()]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames25_ES6.js b/tests/baselines/reference/computedPropertyNames25_ES6.js index 1a600df5040cf..cc6a0670b2186 100644 --- a/tests/baselines/reference/computedPropertyNames25_ES6.js +++ b/tests/baselines/reference/computedPropertyNames25_ES6.js @@ -14,31 +14,17 @@ class C extends Base { } //// [computedPropertyNames25_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } - C.prototype.foo = function () { +} +class C extends Base { + foo() { var obj = { - [_super.prototype.bar.call(this)]() { + [super.bar()]() { } }; return 0; - }; - return C; -})(Base); + } +} diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt b/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt index 77408f0a9f895..e703971273469 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt +++ b/tests/baselines/reference/computedPropertyNames26_ES5.errors.txt @@ -1,4 +1,4 @@ -tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(10,12): error TS2466: 'super' cannot be referenced in a computed property name. +tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(8,12): error TS2466: 'super' cannot be referenced in a computed property name. ==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts (1 errors) ==== @@ -8,8 +8,6 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts(10 } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [ { [super.bar()]: 1 }[0] ~~~~~ diff --git a/tests/baselines/reference/computedPropertyNames26_ES5.js b/tests/baselines/reference/computedPropertyNames26_ES5.js index 217a0dfc74cff..5651ee266c94e 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES5.js +++ b/tests/baselines/reference/computedPropertyNames26_ES5.js @@ -5,8 +5,6 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [ { [super.bar()]: 1 }[0] ]() { } @@ -32,10 +30,8 @@ var C = (function (_super) { function C() { _super.apply(this, arguments); } - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. C.prototype[(_a = {}, - _a[super.bar.call(this)] = 1, + _a[_super.bar.call(this)] = 1, _a)[0]] = function () { }; return C; diff --git a/tests/baselines/reference/computedPropertyNames26_ES6.js b/tests/baselines/reference/computedPropertyNames26_ES6.js index fc53d91e627dd..4526368de7a0a 100644 --- a/tests/baselines/reference/computedPropertyNames26_ES6.js +++ b/tests/baselines/reference/computedPropertyNames26_ES6.js @@ -13,30 +13,16 @@ class C extends Base { } //// [computedPropertyNames26_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } +} +class C extends Base { // Gets emitted as super, not _super, which is consistent with // use of super in static properties initializers. - C.prototype[{ - [super.bar.call(this)]: 1 - }[0]] = function () { - }; - return C; -})(Base); + [{ + [super.bar()]: 1 + }[0]]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames27_ES6.js b/tests/baselines/reference/computedPropertyNames27_ES6.js index 54a20a5220058..57589dfcaf507 100644 --- a/tests/baselines/reference/computedPropertyNames27_ES6.js +++ b/tests/baselines/reference/computedPropertyNames27_ES6.js @@ -6,23 +6,9 @@ class C extends Base { } //// [computedPropertyNames27_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); +class Base { +} +class C extends Base { + [(super(), "prop")]() { } - C.prototype[(_super.call(this), "prop")] = function () { - }; - return C; -})(Base); +} diff --git a/tests/baselines/reference/computedPropertyNames28_ES6.js b/tests/baselines/reference/computedPropertyNames28_ES6.js index 09e1b33bf981d..bc0e32593de1f 100644 --- a/tests/baselines/reference/computedPropertyNames28_ES6.js +++ b/tests/baselines/reference/computedPropertyNames28_ES6.js @@ -11,25 +11,14 @@ class C extends Base { } //// [computedPropertyNames28_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.call(this); +class Base { +} +class C extends Base { + constructor() { + super(); var obj = { - [(_super.call(this), "prop")]() { + [(super(), "prop")]() { } }; } - return C; -})(Base); +} diff --git a/tests/baselines/reference/computedPropertyNames29_ES6.js b/tests/baselines/reference/computedPropertyNames29_ES6.js index e1e6be51b2155..35958b372b09c 100644 --- a/tests/baselines/reference/computedPropertyNames29_ES6.js +++ b/tests/baselines/reference/computedPropertyNames29_ES6.js @@ -11,10 +11,8 @@ class C { } //// [computedPropertyNames29_ES6.js] -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { (() => { var obj = { [this.bar()]() { @@ -22,6 +20,5 @@ var C = (function () { }; }); return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames2_ES6.js b/tests/baselines/reference/computedPropertyNames2_ES6.js index e5fcfaac8f927..4287cb2c4b8d7 100644 --- a/tests/baselines/reference/computedPropertyNames2_ES6.js +++ b/tests/baselines/reference/computedPropertyNames2_ES6.js @@ -13,36 +13,17 @@ class C { //// [computedPropertyNames2_ES6.js] var methodName = "method"; var accessorName = "accessor"; -var C = (function () { - function C() { +class C { + [methodName]() { } - C.prototype[methodName] = function () { - }; - C[methodName] = function () { - }; - Object.defineProperty(C.prototype, accessorName, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, accessorName, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, accessorName, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, accessorName, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + static [methodName]() { + } + get [accessorName]() { + } + set [accessorName](v) { + } + static get [accessorName]() { + } + static set [accessorName](v) { + } +} diff --git a/tests/baselines/reference/computedPropertyNames30_ES6.js b/tests/baselines/reference/computedPropertyNames30_ES6.js index c88fa98be5e86..cda2a278d47aa 100644 --- a/tests/baselines/reference/computedPropertyNames30_ES6.js +++ b/tests/baselines/reference/computedPropertyNames30_ES6.js @@ -16,30 +16,19 @@ class C extends Base { } //// [computedPropertyNames30_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.call(this); +class Base { +} +class C extends Base { + constructor() { + super(); (() => { var obj = { // Ideally, we would capture this. But the reference is // illegal, and not capturing this is consistent with //treatment of other similar violations. - [(_super.call(this), "prop")]() { + [(super(), "prop")]() { } }; }); } - return C; -})(Base); +} diff --git a/tests/baselines/reference/computedPropertyNames31_ES6.js b/tests/baselines/reference/computedPropertyNames31_ES6.js index 33f5319ded98b..777e03bbcacad 100644 --- a/tests/baselines/reference/computedPropertyNames31_ES6.js +++ b/tests/baselines/reference/computedPropertyNames31_ES6.js @@ -16,34 +16,20 @@ class C extends Base { } //// [computedPropertyNames31_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Base = (function () { - function Base() { - } - Base.prototype.bar = function () { +class Base { + bar() { return 0; - }; - return Base; -})(); -var C = (function (_super) { - __extends(C, _super); - function C() { - _super.apply(this, arguments); } - C.prototype.foo = function () { +} +class C extends Base { + foo() { var _this = this; (() => { var obj = { - [_super.prototype.bar.call(_this)]() { + [super.bar()]() { } // needs capture }; }); return 0; - }; - return C; -})(Base); + } +} diff --git a/tests/baselines/reference/computedPropertyNames32_ES6.js b/tests/baselines/reference/computedPropertyNames32_ES6.js index a87f7715d890e..198c5e9981e58 100644 --- a/tests/baselines/reference/computedPropertyNames32_ES6.js +++ b/tests/baselines/reference/computedPropertyNames32_ES6.js @@ -11,13 +11,10 @@ class C { function foo() { return ''; } -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { return 0; - }; - C.prototype[foo()] = function () { - }; - return C; -})(); + } + [foo()]() { + } +} diff --git a/tests/baselines/reference/computedPropertyNames33_ES6.js b/tests/baselines/reference/computedPropertyNames33_ES6.js index 03c503caec45d..7fb08d2852d8d 100644 --- a/tests/baselines/reference/computedPropertyNames33_ES6.js +++ b/tests/baselines/reference/computedPropertyNames33_ES6.js @@ -13,15 +13,12 @@ class C { function foo() { return ''; } -var C = (function () { - function C() { - } - C.prototype.bar = function () { +class C { + bar() { var obj = { [foo()]() { } }; return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames34_ES6.js b/tests/baselines/reference/computedPropertyNames34_ES6.js index 62e2e151cd3ac..e73d349bcd73f 100644 --- a/tests/baselines/reference/computedPropertyNames34_ES6.js +++ b/tests/baselines/reference/computedPropertyNames34_ES6.js @@ -13,15 +13,12 @@ class C { function foo() { return ''; } -var C = (function () { - function C() { - } - C.bar = function () { +class C { + static bar() { var obj = { [foo()]() { } }; return 0; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames36_ES6.js b/tests/baselines/reference/computedPropertyNames36_ES6.js index 5b71326fbc459..573b8fa0c17b4 100644 --- a/tests/baselines/reference/computedPropertyNames36_ES6.js +++ b/tests/baselines/reference/computedPropertyNames36_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames36_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get ["get1"]() { + return new Foo; } - return Foo2; -})(); -var C = (function () { - function C() { + set ["set1"](p) { } - Object.defineProperty(C.prototype, "get1", { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames37_ES6.js b/tests/baselines/reference/computedPropertyNames37_ES6.js index 992035f68657d..d62c95e6f8c12 100644 --- a/tests/baselines/reference/computedPropertyNames37_ES6.js +++ b/tests/baselines/reference/computedPropertyNames37_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames37_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get ["get1"]() { + return new Foo; } - return Foo2; -})(); -var C = (function () { - function C() { + set ["set1"](p) { } - Object.defineProperty(C.prototype, "get1", { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames38_ES6.js b/tests/baselines/reference/computedPropertyNames38_ES6.js index 0fdcdb1d63cb9..cf1d01873f296 100644 --- a/tests/baselines/reference/computedPropertyNames38_ES6.js +++ b/tests/baselines/reference/computedPropertyNames38_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames38_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get [1 << 6]() { + return new Foo; } - return Foo2; -})(); -var C = (function () { - function C() { + set [1 << 6](p) { } - Object.defineProperty(C.prototype, 1 << 6, { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, 1 << 6, { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames39_ES6.js b/tests/baselines/reference/computedPropertyNames39_ES6.js index 8e458ad83d7df..9afd60b6464ef 100644 --- a/tests/baselines/reference/computedPropertyNames39_ES6.js +++ b/tests/baselines/reference/computedPropertyNames39_ES6.js @@ -11,32 +11,15 @@ class C { } //// [computedPropertyNames39_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { +class Foo { +} +class Foo2 { +} +class C { + // Computed properties + get [1 << 6]() { + return new Foo; } - return Foo2; -})(); -var C = (function () { - function C() { + set [1 << 6](p) { } - Object.defineProperty(C.prototype, 1 << 6, { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, 1 << 6, { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt index 3df6d6d97440d..b90091123473a 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt +++ b/tests/baselines/reference/computedPropertyNames3_ES6.errors.txt @@ -1,12 +1,13 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. +tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(5,17): error TS1102: 'delete' cannot be called on an identifier in strict mode. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. -==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (6 errors) ==== +==== tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts (7 errors) ==== var id; class C { [0 + 1]() { } @@ -18,6 +19,8 @@ tests/cases/conformance/es6/computedProperties/computedPropertyNames3_ES6.ts(7,1 !!! error TS2378: A 'get' accessor must return a value or consist of a single 'throw' statement. ~~~~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. + ~~ +!!! error TS1102: 'delete' cannot be called on an identifier in strict mode. set [[0, 1]](v) { } ~~~~~~~~ !!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'. diff --git a/tests/baselines/reference/computedPropertyNames3_ES6.js b/tests/baselines/reference/computedPropertyNames3_ES6.js index 1a9c9ee465b2e..b5fb9e88001f4 100644 --- a/tests/baselines/reference/computedPropertyNames3_ES6.js +++ b/tests/baselines/reference/computedPropertyNames3_ES6.js @@ -11,40 +11,21 @@ class C { //// [computedPropertyNames3_ES6.js] var id; -var C = (function () { - function C() { +class C { + [0 + 1]() { } - C.prototype[0 + 1] = function () { - }; - C[() => { - }] = function () { - }; - Object.defineProperty(C.prototype, delete id, { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, [ + static [() => { + }]() { + } + get [delete id]() { + } + set [[ 0, 1 - ], { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, "", { - get: function () { - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, id.toString(), { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + ]](v) { + } + static get [""]() { + } + static set [id.toString()](v) { + } +} diff --git a/tests/baselines/reference/computedPropertyNames40_ES6.js b/tests/baselines/reference/computedPropertyNames40_ES6.js index 99d28688a298f..c4820e0ca9823 100644 --- a/tests/baselines/reference/computedPropertyNames40_ES6.js +++ b/tests/baselines/reference/computedPropertyNames40_ES6.js @@ -11,25 +11,16 @@ class C { } //// [computedPropertyNames40_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { - } +class Foo { +} +class Foo2 { +} +class C { // Computed properties - C.prototype[""] = function () { + [""]() { return new Foo; - }; - C.prototype[""] = function () { + } + [""]() { return new Foo2; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames41_ES6.js b/tests/baselines/reference/computedPropertyNames41_ES6.js index f0c386706a3f7..5773f892fd597 100644 --- a/tests/baselines/reference/computedPropertyNames41_ES6.js +++ b/tests/baselines/reference/computedPropertyNames41_ES6.js @@ -10,22 +10,13 @@ class C { } //// [computedPropertyNames41_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { - } +class Foo { +} +class Foo2 { +} +class C { // Computed properties - C[""] = function () { + static [""]() { return new Foo; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/computedPropertyNames42_ES6.js b/tests/baselines/reference/computedPropertyNames42_ES6.js index 8538088f4500a..b6114f06bac84 100644 --- a/tests/baselines/reference/computedPropertyNames42_ES6.js +++ b/tests/baselines/reference/computedPropertyNames42_ES6.js @@ -10,18 +10,9 @@ class C { } //// [computedPropertyNames42_ES6.js] -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { - } - return C; -})(); +class Foo { +} +class Foo2 { +} +class C { +} diff --git a/tests/baselines/reference/computedPropertyNames43_ES6.js b/tests/baselines/reference/computedPropertyNames43_ES6.js index ba0c228c30738..ab9d09834d20a 100644 --- a/tests/baselines/reference/computedPropertyNames43_ES6.js +++ b/tests/baselines/reference/computedPropertyNames43_ES6.js @@ -13,45 +13,17 @@ class D extends C { } //// [computedPropertyNames43_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { +class Foo { +} +class Foo2 { +} +class C { +} +class D extends C { + // Computed properties + get ["get1"]() { + return new Foo; } - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.apply(this, arguments); + set ["set1"](p) { } - Object.defineProperty(D.prototype, "get1", { - // Computed properties - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(D.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return D; -})(C); +} diff --git a/tests/baselines/reference/computedPropertyNames44_ES6.js b/tests/baselines/reference/computedPropertyNames44_ES6.js index 72729054e076f..13d46131e924b 100644 --- a/tests/baselines/reference/computedPropertyNames44_ES6.js +++ b/tests/baselines/reference/computedPropertyNames44_ES6.js @@ -12,44 +12,16 @@ class D extends C { } //// [computedPropertyNames44_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { +class Foo { +} +class Foo2 { +} +class C { + get ["get1"]() { + return new Foo; } - Object.defineProperty(C.prototype, "get1", { - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.apply(this, arguments); +} +class D extends C { + set ["set1"](p) { } - Object.defineProperty(D.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return D; -})(C); +} diff --git a/tests/baselines/reference/computedPropertyNames45_ES6.js b/tests/baselines/reference/computedPropertyNames45_ES6.js index 23dccc7795691..bea5f5211ea7d 100644 --- a/tests/baselines/reference/computedPropertyNames45_ES6.js +++ b/tests/baselines/reference/computedPropertyNames45_ES6.js @@ -13,44 +13,16 @@ class D extends C { } //// [computedPropertyNames45_ES6.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var Foo2 = (function () { - function Foo2() { - } - return Foo2; -})(); -var C = (function () { - function C() { +class Foo { +} +class Foo2 { +} +class C { + get ["get1"]() { + return new Foo; } - Object.defineProperty(C.prototype, "get1", { - get: function () { - return new Foo; - }, - enumerable: true, - configurable: true - }); - return C; -})(); -var D = (function (_super) { - __extends(D, _super); - function D() { - _super.apply(this, arguments); +} +class D extends C { + set ["set1"](p) { } - Object.defineProperty(D.prototype, "set1", { - set: function (p) { - }, - enumerable: true, - configurable: true - }); - return D; -})(C); +} diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js index eb7dab0b660f4..f234ae0d97e2b 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit1_ES6.js @@ -6,26 +6,15 @@ class C { } //// [computedPropertyNamesDeclarationEmit1_ES6.js] -var C = (function () { - function C() { +class C { + ["" + ""]() { } - C.prototype["" + ""] = function () { - }; - Object.defineProperty(C.prototype, "" + "", { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, "" + "", { - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get ["" + ""]() { + return 0; + } + set ["" + ""](x) { + } +} //// [computedPropertyNamesDeclarationEmit1_ES6.d.ts] diff --git a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js index 3912113905c84..b5e70193b0d11 100644 --- a/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesDeclarationEmit2_ES6.js @@ -6,26 +6,15 @@ class C { } //// [computedPropertyNamesDeclarationEmit2_ES6.js] -var C = (function () { - function C() { +class C { + static ["" + ""]() { } - C["" + ""] = function () { - }; - Object.defineProperty(C, "" + "", { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C, "" + "", { - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + static get ["" + ""]() { + return 0; + } + static set ["" + ""](x) { + } +} //// [computedPropertyNamesDeclarationEmit2_ES6.d.ts] diff --git a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js index 264a6a75074b1..ced0a8d449a2e 100644 --- a/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesOnOverloads_ES6.js @@ -10,10 +10,7 @@ class C { //// [computedPropertyNamesOnOverloads_ES6.js] var methodName = "method"; var accessorName = "accessor"; -var C = (function () { - function C() { +class C { + [methodName](v) { } - C.prototype[methodName] = function (v) { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js index f7dc9e1783690..749ab99b18b02 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js @@ -6,12 +6,9 @@ class C { } //// [computedPropertyNamesSourceMap1_ES6.js] -var C = (function () { - function C() { - } - C.prototype["hello"] = function () { +class C { + ["hello"]() { debugger; - }; - return C; -})(); + } +} //# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map index 20765a5b2d4e2..9a2dd60999ef8 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.js.map @@ -1,2 +1,2 @@ //// [computedPropertyNamesSourceMap1_ES6.js.map] -{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":["C","C.constructor","C[\"hello\"]"],"mappings":"AAAA;IAAAA;IAIAC,CAACA;IAHGD,YAACA,OAAOA,CAACA,GAATA;QACIE,QAAQA,CAACA;IACbA,CAACA;IACLF,QAACA;AAADA,CAACA,AAJD,IAIC"} \ No newline at end of file +{"version":3,"file":"computedPropertyNamesSourceMap1_ES6.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap1_ES6.ts"],"names":["C","C[\"hello\"]"],"mappings":"AAAA;IACIA,CAACA,OAAOA,CAACA;QACLC,QAAQA,CAACA;IACbA,CAACA;AACLD,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt index 64713447e4333..30493b9734737 100644 --- a/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt +++ b/tests/baselines/reference/computedPropertyNamesSourceMap1_ES6.sourcemap.txt @@ -8,96 +8,61 @@ sources: computedPropertyNamesSourceMap1_ES6.ts emittedFile:tests/cases/conformance/es6/computedProperties/computedPropertyNamesSourceMap1_ES6.js sourceFile:computedPropertyNamesSourceMap1_ES6.ts ------------------------------------------------------------------- ->>>var C = (function () { +>>>class C { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^-> 1 > 1 >Emitted(1, 1) Source(1, 1) + SourceIndex(0) --- ->>> function C() { -1->^^^^ -2 > ^^-> -1-> -1->Emitted(2, 5) Source(1, 1) + SourceIndex(0) name (C) ---- ->>> } +>>> ["hello"]() { 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^^^ +4 > ^ +5 > ^^^^^-> 1->class C { - > ["hello"]() { - > debugger; - > } - > -2 > } -1->Emitted(3, 5) Source(5, 1) + SourceIndex(0) name (C.constructor) -2 >Emitted(3, 6) Source(5, 2) + SourceIndex(0) name (C.constructor) ---- ->>> C.prototype["hello"] = function () { -1->^^^^ -2 > ^^^^^^^^^^^^ -3 > ^^^^^^^ -4 > ^ -5 > ^^^ -1-> + > 2 > [ -3 > "hello" -4 > ] -5 > -1->Emitted(4, 5) Source(2, 5) + SourceIndex(0) name (C) -2 >Emitted(4, 17) Source(2, 6) + SourceIndex(0) name (C) -3 >Emitted(4, 24) Source(2, 13) + SourceIndex(0) name (C) -4 >Emitted(4, 25) Source(2, 14) + SourceIndex(0) name (C) -5 >Emitted(4, 28) Source(2, 5) + SourceIndex(0) name (C) +3 > "hello" +4 > ] +1->Emitted(2, 5) Source(2, 5) + SourceIndex(0) name (C) +2 >Emitted(2, 6) Source(2, 6) + SourceIndex(0) name (C) +3 >Emitted(2, 13) Source(2, 13) + SourceIndex(0) name (C) +4 >Emitted(2, 14) Source(2, 14) + SourceIndex(0) name (C) --- >>> debugger; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^^^ 3 > ^ -1 >["hello"]() { +1->() { > 2 > debugger 3 > ; -1 >Emitted(5, 9) Source(3, 9) + SourceIndex(0) name (C["hello"]) -2 >Emitted(5, 17) Source(3, 17) + SourceIndex(0) name (C["hello"]) -3 >Emitted(5, 18) Source(3, 18) + SourceIndex(0) name (C["hello"]) +1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (C["hello"]) +2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) name (C["hello"]) +3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) name (C["hello"]) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } -1 >Emitted(6, 5) Source(4, 5) + SourceIndex(0) name (C["hello"]) -2 >Emitted(6, 6) Source(4, 6) + SourceIndex(0) name (C["hello"]) ---- ->>> return C; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(5, 1) + SourceIndex(0) name (C) -2 >Emitted(7, 13) Source(5, 2) + SourceIndex(0) name (C) +1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) name (C["hello"]) +2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) name (C["hello"]) --- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class C { - > ["hello"]() { - > debugger; - > } - > } -1 >Emitted(8, 1) Source(5, 1) + SourceIndex(0) name (C) -2 >Emitted(8, 2) Source(5, 2) + SourceIndex(0) name (C) -3 >Emitted(8, 2) Source(1, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(5, 2) + SourceIndex(0) +1 >Emitted(5, 1) Source(5, 1) + SourceIndex(0) name (C) +2 >Emitted(5, 2) Source(5, 2) + SourceIndex(0) name (C) --- ->>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map \ No newline at end of file +>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(6, 1) Source(5, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.js b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.js new file mode 100644 index 0000000000000..e6b7bd5aae2de --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.js @@ -0,0 +1,24 @@ +//// [computedPropertyNamesWithStaticProperty.ts] +class C { + static staticProp = 10; + get [C.staticProp]() { + return "hello"; + } + set [C.staticProp](x: string) { + var y = x; + } + [C.staticProp]() { } +} + +//// [computedPropertyNamesWithStaticProperty.js] +class C { + get [C.staticProp]() { + return "hello"; + } + set [C.staticProp](x) { + var y = x; + } + [C.staticProp]() { + } +} +C.staticProp = 10; diff --git a/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types new file mode 100644 index 0000000000000..b23d986f89450 --- /dev/null +++ b/tests/baselines/reference/computedPropertyNamesWithStaticProperty.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts === +class C { +>C : C + + static staticProp = 10; +>staticProp : number + + get [C.staticProp]() { +>C.staticProp : number +>C : typeof C +>staticProp : number + + return "hello"; + } + set [C.staticProp](x: string) { +>C.staticProp : number +>C : typeof C +>staticProp : number +>x : string + + var y = x; +>y : string +>x : string + } + [C.staticProp]() { } +>C.staticProp : number +>C : typeof C +>staticProp : number +} diff --git a/tests/baselines/reference/constDeclarations-scopes.js b/tests/baselines/reference/constDeclarations-scopes.js index f8fbc47312b1b..b144b4f83a553 100644 --- a/tests/baselines/reference/constDeclarations-scopes.js +++ b/tests/baselines/reference/constDeclarations-scopes.js @@ -242,30 +242,25 @@ var m; } })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { const c = 0; n = c; } - C.prototype.method = function () { + method() { const c = 0; n = c; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - const c = 0; - n = c; - return n; - }, - set: function (value) { - const c = 0; - n = c; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + const c = 0; + n = c; + return n; + } + set v(value) { + const c = 0; + n = c; + } +} // object literals var o = { f() { diff --git a/tests/baselines/reference/constDeclarations-validContexts.js b/tests/baselines/reference/constDeclarations-validContexts.js index 5a54e915713ad..7d3269c66832d 100644 --- a/tests/baselines/reference/constDeclarations-validContexts.js +++ b/tests/baselines/reference/constDeclarations-validContexts.js @@ -201,26 +201,21 @@ var m; } })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { const c24 = 0; } - C.prototype.method = function () { + method() { const c25 = 0; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - const c26 = 0; - return c26; - }, - set: function (value) { - const c27 = value; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + const c26 = 0; + return c26; + } + set v(value) { + const c27 = value; + } +} // object literals var o = { f() { diff --git a/tests/baselines/reference/destructuringParameterProperties4.js b/tests/baselines/reference/destructuringParameterProperties4.js index 6da6f53a4fe04..cd6334c8568cd 100644 --- a/tests/baselines/reference/destructuringParameterProperties4.js +++ b/tests/baselines/reference/destructuringParameterProperties4.js @@ -28,38 +28,26 @@ class C2 extends C1 { //// [destructuringParameterProperties4.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1(k, [a, b, c]) { +class C1 { + constructor(k, [a, b, c]) { this.k = k; this.[a, b, c] = [a, b, c]; if ((b === undefined && c === undefined) || (this.b === undefined && this.c === undefined)) { this.a = a || k; } } - C1.prototype.getA = function () { + getA() { return this.a; - }; - C1.prototype.getB = function () { + } + getB() { return this.b; - }; - C1.prototype.getC = function () { + } + getC() { return this.c; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - C2.prototype.doSomethingWithSuperProperties = function () { +} +class C2 extends C1 { + doSomethingWithSuperProperties() { return `${this.a} ${this.b} ${this.c}`; - }; - return C2; -})(C1); + } +} diff --git a/tests/baselines/reference/emitClassDeclarationOverloadInES6.js b/tests/baselines/reference/emitClassDeclarationOverloadInES6.js new file mode 100644 index 0000000000000..4cf96778f3f4d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationOverloadInES6.js @@ -0,0 +1,21 @@ +//// [emitClassDeclarationOverloadInES6.ts] +class C { + constructor(y: any) + constructor(x: number) { + } +} + +class D { + constructor(y: any) + constructor(x: number, z="hello") {} +} + +//// [emitClassDeclarationOverloadInES6.js] +class C { + constructor(x) { + } +} +class D { + constructor(x, z = "hello") { + } +} diff --git a/tests/baselines/reference/emitClassDeclarationOverloadInES6.types b/tests/baselines/reference/emitClassDeclarationOverloadInES6.types new file mode 100644 index 0000000000000..850a5aa545621 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationOverloadInES6.types @@ -0,0 +1,22 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts === +class C { +>C : C + + constructor(y: any) +>y : any + + constructor(x: number) { +>x : number + } +} + +class D { +>D : D + + constructor(y: any) +>y : any + + constructor(x: number, z="hello") {} +>x : number +>z : string +} diff --git a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.js b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.js new file mode 100644 index 0000000000000..8c115b17e9c2c --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.js @@ -0,0 +1,42 @@ +//// [emitClassDeclarationWithConstructorInES6.ts] +class A { + y: number; + constructor(x: number) { + } + foo(a: any); + foo() { } +} + +class B { + y: number; + x: string = "hello"; + _bar: string; + + constructor(x: number, z = "hello", ...args) { + this.y = 10; + } + baz(...args): string; + baz(z: string, v: number): string { + return this._bar; + } +} + + + + +//// [emitClassDeclarationWithConstructorInES6.js] +class A { + constructor(x) { + } + foo() { + } +} +class B { + constructor(x, z = "hello", ...args) { + this.x = "hello"; + this.y = 10; + } + baz(z, v) { + return this._bar; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types new file mode 100644 index 0000000000000..10244bf61702d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithConstructorInES6.types @@ -0,0 +1,59 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts === +class A { +>A : A + + y: number; +>y : number + + constructor(x: number) { +>x : number + } + foo(a: any); +>foo : (a: any) => any +>a : any + + foo() { } +>foo : (a: any) => any +} + +class B { +>B : B + + y: number; +>y : number + + x: string = "hello"; +>x : string + + _bar: string; +>_bar : string + + constructor(x: number, z = "hello", ...args) { +>x : number +>z : string +>args : any[] + + this.y = 10; +>this.y = 10 : number +>this.y : number +>this : B +>y : number + } + baz(...args): string; +>baz : (...args: any[]) => string +>args : any[] + + baz(z: string, v: number): string { +>baz : (...args: any[]) => string +>z : string +>v : number + + return this._bar; +>this._bar : string +>this : B +>_bar : string + } +} + + + diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.js b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.js new file mode 100644 index 0000000000000..cd217af6a81d3 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.js @@ -0,0 +1,24 @@ +//// [emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts] +class B { + constructor(a: T) { } +} +class C extends B { } +class D extends B { + constructor(a: any) + constructor(b: number) { + super(b); + } +} + +//// [emitClassDeclarationWithExtensionAndTypeArgumentInES6.js] +class B { + constructor(a) { + } +} +class C extends B { +} +class D extends B { + constructor(b) { + super(b); + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types new file mode 100644 index 0000000000000..0f546fa7b8620 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionAndTypeArgumentInES6.types @@ -0,0 +1,29 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts === +class B { +>B : B +>T : T + + constructor(a: T) { } +>a : T +>T : T +} +class C extends B { } +>C : C +>B : B + +class D extends B { +>D : D +>B : B + + constructor(a: any) +>a : any + + constructor(b: number) { +>b : number + + super(b); +>super(b) : void +>super : typeof B +>b : number + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.js b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.js new file mode 100644 index 0000000000000..5c64aebd16a56 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.js @@ -0,0 +1,48 @@ +//// [emitClassDeclarationWithExtensionInES6.ts] +class B { + baz(a: string, y = 10) { } +} +class C extends B { + foo() { } + baz(a: string, y:number) { + super.baz(a, y); + } +} +class D extends C { + constructor() { + super(); + } + + foo() { + super.foo(); + } + + baz() { + super.baz("hello", 10); + } +} + + +//// [emitClassDeclarationWithExtensionInES6.js] +class B { + baz(a, y = 10) { + } +} +class C extends B { + foo() { + } + baz(a, y) { + super.baz(a, y); + } +} +class D extends C { + constructor() { + super(); + } + foo() { + super.foo(); + } + baz() { + super.baz("hello", 10); + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types new file mode 100644 index 0000000000000..a1549be5df4ac --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithExtensionInES6.types @@ -0,0 +1,61 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts === +class B { +>B : B + + baz(a: string, y = 10) { } +>baz : (a: string, y?: number) => void +>a : string +>y : number +} +class C extends B { +>C : C +>B : B + + foo() { } +>foo : () => void + + baz(a: string, y:number) { +>baz : (a: string, y: number) => void +>a : string +>y : number + + super.baz(a, y); +>super.baz(a, y) : void +>super.baz : (a: string, y?: number) => void +>super : B +>baz : (a: string, y?: number) => void +>a : string +>y : number + } +} +class D extends C { +>D : D +>C : C + + constructor() { + super(); +>super() : void +>super : typeof C + } + + foo() { +>foo : () => void + + super.foo(); +>super.foo() : void +>super.foo : () => void +>super : C +>foo : () => void + } + + baz() { +>baz : () => void + + super.baz("hello", 10); +>super.baz("hello", 10) : void +>super.baz : (a: string, y: number) => void +>super : C +>baz : (a: string, y: number) => void + } +} + diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.js b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.js new file mode 100644 index 0000000000000..68ccd1568edd7 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.js @@ -0,0 +1,57 @@ +//// [emitClassDeclarationWithGetterSetterInES6.ts] +class C { + _name: string; + get name(): string { + return this._name; + } + static get name2(): string { + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + + set ["computedname"](x: any) { + } + set ["computedname"](y: string) { + } + + set foo(a: string) { } + static set bar(b: number) { } + static set ["computedname"](b: string) { } +} + +//// [emitClassDeclarationWithGetterSetterInES6.js] +class C { + get name() { + return this._name; + } + static get name2() { + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + set ["computedname"](x) { + } + set ["computedname"](y) { + } + set foo(a) { + } + static set bar(b) { + } + static set ["computedname"](b) { + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types new file mode 100644 index 0000000000000..83d4fcd0d802f --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithGetterSetterInES6.types @@ -0,0 +1,48 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts === +class C { +>C : C + + _name: string; +>_name : string + + get name(): string { +>name : string + + return this._name; +>this._name : string +>this : C +>_name : string + } + static get name2(): string { +>name2 : string + + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + + set ["computedname"](x: any) { +>x : any + } + set ["computedname"](y: string) { +>y : string + } + + set foo(a: string) { } +>foo : string +>a : string + + static set bar(b: number) { } +>bar : number +>b : number + + static set ["computedname"](b: string) { } +>b : string +} diff --git a/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.js b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.js new file mode 100644 index 0000000000000..d82750f276fcc --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.js @@ -0,0 +1,37 @@ +//// [emitClassDeclarationWithLiteralPropertyNameInES6.ts] +class B { + "hello" = 10; + 0b110 = "world"; + 0o23534 = "WORLD"; + 20 = "twenty"; + "foo"() { } + 0b1110() {} + 11() { } + interface() { } + static "hi" = 10000; + static 22 = "twenty-two"; + static 0b101 = "binary"; + static 0o3235 = "octal"; +} + +//// [emitClassDeclarationWithLiteralPropertyNameInES6.js] +class B { + constructor() { + this["hello"] = 10; + this[0b110] = "world"; + this[0o23534] = "WORLD"; + this[20] = "twenty"; + } + "foo"() { + } + 0b1110() { + } + 11() { + } + interface() { + } +} +B["hi"] = 10000; +B[22] = "twenty-two"; +B[0b101] = "binary"; +B[0o3235] = "octal"; diff --git a/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types new file mode 100644 index 0000000000000..65ba8f7d2b9b0 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithLiteralPropertyNameInES6.types @@ -0,0 +1,19 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts === +class B { +>B : B + + "hello" = 10; + 0b110 = "world"; + 0o23534 = "WORLD"; + 20 = "twenty"; + "foo"() { } + 0b1110() {} + 11() { } + interface() { } +>interface : () => void + + static "hi" = 10000; + static 22 = "twenty-two"; + static 0b101 = "binary"; + static 0o3235 = "octal"; +} diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.js b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.js new file mode 100644 index 0000000000000..20f58b4274e1d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.js @@ -0,0 +1,58 @@ +//// [emitClassDeclarationWithMethodInES6.ts] +class D { + _bar: string; + foo() { } + ["computedName"]() { } + ["computedName"](a: string) { } + ["computedName"](a: string): number { return 1; } + bar(): string { + return this._bar; + } + baz(a: any, x: string): string { + return "HELLO"; + } + static ["computedname"]() { } + static ["computedname"](a: string) { } + static ["computedname"](a: string): boolean { return true; } + static staticMethod() { + var x = 1 + 2; + return x + } + static foo(a: string) { } + static bar(a: string): number { return 1; } +} + +//// [emitClassDeclarationWithMethodInES6.js] +class D { + foo() { + } + ["computedName"]() { + } + ["computedName"](a) { + } + ["computedName"](a) { + return 1; + } + bar() { + return this._bar; + } + baz(a, x) { + return "HELLO"; + } + static ["computedname"]() { + } + static ["computedname"](a) { + } + static ["computedname"](a) { + return true; + } + static staticMethod() { + var x = 1 + 2; + return x; + } + static foo(a) { + } + static bar(a) { + return 1; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types new file mode 100644 index 0000000000000..f26a9f87e6d25 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithMethodInES6.types @@ -0,0 +1,57 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts === +class D { +>D : D + + _bar: string; +>_bar : string + + foo() { } +>foo : () => void + + ["computedName"]() { } + ["computedName"](a: string) { } +>a : string + + ["computedName"](a: string): number { return 1; } +>a : string + + bar(): string { +>bar : () => string + + return this._bar; +>this._bar : string +>this : D +>_bar : string + } + baz(a: any, x: string): string { +>baz : (a: any, x: string) => string +>a : any +>x : string + + return "HELLO"; + } + static ["computedname"]() { } + static ["computedname"](a: string) { } +>a : string + + static ["computedname"](a: string): boolean { return true; } +>a : string + + static staticMethod() { +>staticMethod : () => number + + var x = 1 + 2; +>x : number +>1 + 2 : number + + return x +>x : number + } + static foo(a: string) { } +>foo : (a: string) => void +>a : string + + static bar(a: string): number { return 1; } +>bar : (a: string) => number +>a : string +} diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js new file mode 100644 index 0000000000000..03fb45b806e3d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.js @@ -0,0 +1,51 @@ +//// [emitClassDeclarationWithPropertyAssignmentInES6.ts] +class C { + x: string = "Hello world"; +} + +class D { + x: string = "Hello world"; + y: number; + constructor() { + this.y = 10; + } +} + +class E extends D{ + z: boolean = true; +} + +class F extends D{ + z: boolean = true; + j: string; + constructor() { + super(); + this.j = "HI"; + } +} + +//// [emitClassDeclarationWithPropertyAssignmentInES6.js] +class C { + constructor() { + this.x = "Hello world"; + } +} +class D { + constructor() { + this.x = "Hello world"; + this.y = 10; + } +} +class E extends D { + constructor(...args) { + super(...args); + this.z = true; + } +} +class F extends D { + constructor() { + super(); + this.z = true; + this.j = "HI"; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types new file mode 100644 index 0000000000000..5e7ebbc167c70 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithPropertyAssignmentInES6.types @@ -0,0 +1,56 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts === +class C { +>C : C + + x: string = "Hello world"; +>x : string +} + +class D { +>D : D + + x: string = "Hello world"; +>x : string + + y: number; +>y : number + + constructor() { + this.y = 10; +>this.y = 10 : number +>this.y : number +>this : D +>y : number + } +} + +class E extends D{ +>E : E +>D : D + + z: boolean = true; +>z : boolean +} + +class F extends D{ +>F : F +>D : D + + z: boolean = true; +>z : boolean + + j: string; +>j : string + + constructor() { + super(); +>super() : void +>super : typeof D + + this.j = "HI"; +>this.j = "HI" : string +>this.j : string +>this : F +>j : string + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.js b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.js new file mode 100644 index 0000000000000..8e0bf3de06bcd --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.js @@ -0,0 +1,21 @@ +//// [emitClassDeclarationWithStaticPropertyAssignmentInES6.ts] +class C { + static z: string = "Foo"; +} + +class D { + x = 20000; + static b = true; +} + + +//// [emitClassDeclarationWithStaticPropertyAssignmentInES6.js] +class C { +} +C.z = "Foo"; +class D { + constructor() { + this.x = 20000; + } +} +D.b = true; diff --git a/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types new file mode 100644 index 0000000000000..6003b85b590ee --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithStaticPropertyAssignmentInES6.types @@ -0,0 +1,18 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts === +class C { +>C : C + + static z: string = "Foo"; +>z : string +} + +class D { +>D : D + + x = 20000; +>x : number + + static b = true; +>b : boolean +} + diff --git a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.js b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.js new file mode 100644 index 0000000000000..14f74682c008d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.js @@ -0,0 +1,38 @@ +//// [emitClassDeclarationWithThisKeywordInES6.ts] +class B { + x = 10; + constructor() { + this.x = 10; + } + static log(a: number) { } + foo() { + B.log(this.x); + } + + get X() { + return this.x; + } + + set bX(y: number) { + this.x = y; + } +} + +//// [emitClassDeclarationWithThisKeywordInES6.js] +class B { + constructor() { + this.x = 10; + this.x = 10; + } + static log(a) { + } + foo() { + B.log(this.x); + } + get X() { + return this.x; + } + set bX(y) { + this.x = y; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types new file mode 100644 index 0000000000000..bb0f7e9993977 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithThisKeywordInES6.types @@ -0,0 +1,52 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts === +class B { +>B : B + + x = 10; +>x : number + + constructor() { + this.x = 10; +>this.x = 10 : number +>this.x : number +>this : B +>x : number + } + static log(a: number) { } +>log : (a: number) => void +>a : number + + foo() { +>foo : () => void + + B.log(this.x); +>B.log(this.x) : void +>B.log : (a: number) => void +>B : typeof B +>log : (a: number) => void +>this.x : number +>this : B +>x : number + } + + get X() { +>X : number + + return this.x; +>this.x : number +>this : B +>x : number + } + + set bX(y: number) { +>bX : number +>y : number + + this.x = y; +>this.x = y : number +>this.x : number +>this : B +>x : number +>y : number + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.js b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.js new file mode 100644 index 0000000000000..8dc5b6cddaabc --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.js @@ -0,0 +1,39 @@ +//// [emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts] +class B { + x: T; + B: T; + + constructor(a: any) + constructor(a: any,b: T) + constructor(a: T) { this.B = a;} + + foo(a: T) + foo(a: any) + foo(b: string) + foo(): T { + return this.x; + } + + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} + +//// [emitClassDeclarationWithTypeArgumentAndOverloadInES6.js] +class B { + constructor(a) { + this.B = a; + } + foo() { + return this.x; + } + get BB() { + return this.B; + } + set BBWith(c) { + this.B = c; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types new file mode 100644 index 0000000000000..ba515168a5d7d --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentAndOverloadInES6.types @@ -0,0 +1,75 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts === +class B { +>B : B +>T : T + + x: T; +>x : T +>T : T + + B: T; +>B : T +>T : T + + constructor(a: any) +>a : any + + constructor(a: any,b: T) +>a : any +>b : T +>T : T + + constructor(a: T) { this.B = a;} +>a : T +>T : T +>this.B = a : T +>this.B : T +>this : B +>B : T +>a : T + + foo(a: T) +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>a : T +>T : T + + foo(a: any) +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>a : any + + foo(b: string) +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>b : string + + foo(): T { +>foo : { (a: T): any; (a: any): any; (b: string): any; } +>T : T + + return this.x; +>this.x : T +>this : B +>x : T + } + + get BB(): T { +>BB : T +>T : T + + return this.B; +>this.B : T +>this : B +>B : T + } + set BBWith(c: T) { +>BBWith : T +>c : T +>T : T + + this.B = c; +>this.B = c : T +>this.B : T +>this : B +>B : T +>c : T + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.js b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.js new file mode 100644 index 0000000000000..4e2872b4f0646 --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.js @@ -0,0 +1,31 @@ +//// [emitClassDeclarationWithTypeArgumentInES6.ts] +class B { + x: T; + B: T; + constructor(a: T) { this.B = a;} + foo(): T { + return this.x; + } + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} + +//// [emitClassDeclarationWithTypeArgumentInES6.js] +class B { + constructor(a) { + this.B = a; + } + foo() { + return this.x; + } + get BB() { + return this.B; + } + set BBWith(c) { + this.B = c; + } +} diff --git a/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types new file mode 100644 index 0000000000000..8081d044e359e --- /dev/null +++ b/tests/baselines/reference/emitClassDeclarationWithTypeArgumentInES6.types @@ -0,0 +1,53 @@ +=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts === +class B { +>B : B +>T : T + + x: T; +>x : T +>T : T + + B: T; +>B : T +>T : T + + constructor(a: T) { this.B = a;} +>a : T +>T : T +>this.B = a : T +>this.B : T +>this : B +>B : T +>a : T + + foo(): T { +>foo : () => T +>T : T + + return this.x; +>this.x : T +>this : B +>x : T + } + get BB(): T { +>BB : T +>T : T + + return this.B; +>this.B : T +>this : B +>B : T + } + set BBWith(c: T) { +>BBWith : T +>c : T +>T : T + + this.B = c; +>this.B = c : T +>this.B : T +>this : B +>B : T +>c : T + } +} diff --git a/tests/baselines/reference/emitDefaultParametersMethodES6.js b/tests/baselines/reference/emitDefaultParametersMethodES6.js index bf96e00e375fd..3981ddcba3cc6 100644 --- a/tests/baselines/reference/emitDefaultParametersMethodES6.js +++ b/tests/baselines/reference/emitDefaultParametersMethodES6.js @@ -17,26 +17,23 @@ class E { } //// [emitDefaultParametersMethodES6.js] -var C = (function () { - function C(t, z, x, y = "hello") { +class C { + constructor(t, z, x, y = "hello") { } - C.prototype.foo = function (x, t = false) { - }; - C.prototype.foo1 = function (x, t = false, ...rest) { - }; - C.prototype.bar = function (t = false) { - }; - C.prototype.boo = function (t = false, ...rest) { - }; - return C; -})(); -var D = (function () { - function D(y = "hello") { + foo(x, t = false) { } - return D; -})(); -var E = (function () { - function E(y = "hello", ...rest) { + foo1(x, t = false, ...rest) { } - return E; -})(); + bar(t = false) { + } + boo(t = false, ...rest) { + } +} +class D { + constructor(y = "hello") { + } +} +class E { + constructor(y = "hello", ...rest) { + } +} diff --git a/tests/baselines/reference/emitRestParametersMethodES6.js b/tests/baselines/reference/emitRestParametersMethodES6.js index d0a0e2a120ccc..fba6ed01e676f 100644 --- a/tests/baselines/reference/emitRestParametersMethodES6.js +++ b/tests/baselines/reference/emitRestParametersMethodES6.js @@ -15,21 +15,19 @@ class D { //// [emitRestParametersMethodES6.js] -var C = (function () { - function C(name, ...rest) { +class C { + constructor(name, ...rest) { } - C.prototype.bar = function (...rest) { - }; - C.prototype.foo = function (x, ...rest) { - }; - return C; -})(); -var D = (function () { - function D(...rest) { + bar(...rest) { } - D.prototype.bar = function (...rest) { - }; - D.prototype.foo = function (x, ...rest) { - }; - return D; -})(); + foo(x, ...rest) { + } +} +class D { + constructor(...rest) { + } + bar(...rest) { + } + foo(x, ...rest) { + } +} diff --git a/tests/baselines/reference/emitThisInSuperMethodCall.js b/tests/baselines/reference/emitThisInSuperMethodCall.js index 383da7d419f26..de47b0b95aff4 100644 --- a/tests/baselines/reference/emitThisInSuperMethodCall.js +++ b/tests/baselines/reference/emitThisInSuperMethodCall.js @@ -49,20 +49,20 @@ var RegisteredUser = (function (_super) { RegisteredUser.prototype.f = function () { (function () { function inner() { - super.sayHello.call(this); + _super.sayHello.call(this); } }); }; RegisteredUser.prototype.g = function () { function inner() { (function () { - super.sayHello.call(this); + _super.sayHello.call(this); }); } }; RegisteredUser.prototype.h = function () { function inner() { - super.sayHello.call(this); + _super.sayHello.call(this); } }; return RegisteredUser; diff --git a/tests/baselines/reference/errorSuperPropertyAccess.js b/tests/baselines/reference/errorSuperPropertyAccess.js index 17cd2c265edef..4ddcca530f11a 100644 --- a/tests/baselines/reference/errorSuperPropertyAccess.js +++ b/tests/baselines/reference/errorSuperPropertyAccess.js @@ -140,27 +140,27 @@ var __extends = this.__extends || function (d, b) { //super property access in instance member accessor(get and set) of class with no base type var NoBase = (function () { function NoBase() { - this.m = super.prototype; - this.n = super.hasOwnProperty.call(this, ''); - var a = super.prototype; - var b = super.hasOwnProperty.call(this, ''); + this.m = _super.prototype; + this.n = _super.hasOwnProperty.call(this, ''); + var a = _super.prototype; + var b = _super.hasOwnProperty.call(this, ''); } NoBase.prototype.fn = function () { - var a = super.prototype; - var b = super.hasOwnProperty.call(this, ''); + var a = _super.prototype; + var b = _super.hasOwnProperty.call(this, ''); }; //super static property access in static member function of class with no base type //super static property access in static member accessor(get and set) of class with no base type NoBase.static1 = function () { - super.hasOwnProperty.call(this, ''); + _super.hasOwnProperty.call(this, ''); }; Object.defineProperty(NoBase, "static2", { get: function () { - super.hasOwnProperty.call(this, ''); + _super.hasOwnProperty.call(this, ''); return ''; }, set: function (n) { - super.hasOwnProperty.call(this, ''); + _super.hasOwnProperty.call(this, ''); }, enumerable: true, configurable: true @@ -210,11 +210,11 @@ var SomeDerived1 = (function (_super) { }); SomeDerived1.prototype.fn2 = function () { function inner() { - super.publicFunc.call(this); + _super.publicFunc.call(this); } var x = { test: function () { - return super.publicFunc.call(this); + return _super.publicFunc.call(this); } }; }; @@ -278,6 +278,6 @@ var SomeDerived3 = (function (_super) { })(SomeBase); // In object literal var obj = { - n: super.wat, - p: super.foo.call(this) + n: _super.wat, + p: _super.foo.call(this) }; diff --git a/tests/baselines/reference/es6-amd.js b/tests/baselines/reference/es6-amd.js index 0cce3af04463a..74f3037303e35 100644 --- a/tests/baselines/reference/es6-amd.js +++ b/tests/baselines/reference/es6-amd.js @@ -14,14 +14,13 @@ class A } //// [es6-amd.js] -var A = (function () { - function A() { +class A { + constructor() { } - A.prototype.B = function () { + B() { return 42; - }; - return A; -})(); + } +} //# sourceMappingURL=es6-amd.js.map //// [es6-amd.d.ts] diff --git a/tests/baselines/reference/es6-amd.js.map b/tests/baselines/reference/es6-amd.js.map index c9866d87884cb..fe234f8424b52 100644 --- a/tests/baselines/reference/es6-amd.js.map +++ b/tests/baselines/reference/es6-amd.js.map @@ -1,2 +1,2 @@ //// [es6-amd.js.map] -{"version":3,"file":"es6-amd.js","sourceRoot":"","sources":["es6-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file +{"version":3,"file":"es6-amd.js","sourceRoot":"","sources":["es6-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-amd.sourcemap.txt b/tests/baselines/reference/es6-amd.sourcemap.txt index 2b27109940124..1ab547073c61d 100644 --- a/tests/baselines/reference/es6-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-amd.sourcemap.txt @@ -8,14 +8,14 @@ sources: es6-amd.ts emittedFile:tests/cases/compiler/es6-amd.js sourceFile:es6-amd.ts ------------------------------------------------------------------- ->>>var A = (function () { +>>>class A { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^-> 1 > > 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) --- ->>> function A() { +>>> constructor() { 1->^^^^ 2 > ^^-> 1->class A @@ -26,7 +26,7 @@ sourceFile:es6-amd.ts >>> } 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^-> 1->constructor () > { > @@ -35,81 +35,57 @@ sourceFile:es6-amd.ts 1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) 2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) --- ->>> A.prototype.B = function () { +>>> B() { 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> 1-> > > public 2 > B -3 > 1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) --- >>> return 42; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^ 3 > ^ 4 > ^^ 5 > ^ -1 >public B() +1->() > { > 2 > return 3 > 4 > 42 5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) 2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) 3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) 4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) 5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } 1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) --- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) --- ->>>//# sourceMappingURL=es6-amd.js.map \ No newline at end of file +>>>//# sourceMappingURL=es6-amd.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.js b/tests/baselines/reference/es6-declaration-amd.js index 471f96b223d1a..aeba23e0b6ede 100644 --- a/tests/baselines/reference/es6-declaration-amd.js +++ b/tests/baselines/reference/es6-declaration-amd.js @@ -14,14 +14,13 @@ class A } //// [es6-declaration-amd.js] -var A = (function () { - function A() { +class A { + constructor() { } - A.prototype.B = function () { + B() { return 42; - }; - return A; -})(); + } +} //# sourceMappingURL=es6-declaration-amd.js.map //// [es6-declaration-amd.d.ts] diff --git a/tests/baselines/reference/es6-declaration-amd.js.map b/tests/baselines/reference/es6-declaration-amd.js.map index 03f79f6c66778..ca1899e03f559 100644 --- a/tests/baselines/reference/es6-declaration-amd.js.map +++ b/tests/baselines/reference/es6-declaration-amd.js.map @@ -1,2 +1,2 @@ //// [es6-declaration-amd.js.map] -{"version":3,"file":"es6-declaration-amd.js","sourceRoot":"","sources":["es6-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file +{"version":3,"file":"es6-declaration-amd.js","sourceRoot":"","sources":["es6-declaration-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-declaration-amd.sourcemap.txt b/tests/baselines/reference/es6-declaration-amd.sourcemap.txt index 198a68633b1df..9061bc1ed7c48 100644 --- a/tests/baselines/reference/es6-declaration-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-declaration-amd.sourcemap.txt @@ -8,14 +8,14 @@ sources: es6-declaration-amd.ts emittedFile:tests/cases/compiler/es6-declaration-amd.js sourceFile:es6-declaration-amd.ts ------------------------------------------------------------------- ->>>var A = (function () { +>>>class A { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^-> 1 > > 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) --- ->>> function A() { +>>> constructor() { 1->^^^^ 2 > ^^-> 1->class A @@ -26,7 +26,7 @@ sourceFile:es6-declaration-amd.ts >>> } 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^-> 1->constructor () > { > @@ -35,81 +35,57 @@ sourceFile:es6-declaration-amd.ts 1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) 2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) --- ->>> A.prototype.B = function () { +>>> B() { 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> 1-> > > public 2 > B -3 > 1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) --- >>> return 42; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^ 3 > ^ 4 > ^^ 5 > ^ -1 >public B() +1->() > { > 2 > return 3 > 4 > 42 5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) 2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) 3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) 4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) 5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } 1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) --- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) --- ->>>//# sourceMappingURL=es6-declaration-amd.js.map \ No newline at end of file +>>>//# sourceMappingURL=es6-declaration-amd.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.js b/tests/baselines/reference/es6-sourcemap-amd.js index 805e56cf830d0..106726c0f2cfb 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.js +++ b/tests/baselines/reference/es6-sourcemap-amd.js @@ -14,12 +14,11 @@ class A } //// [es6-sourcemap-amd.js] -var A = (function () { - function A() { +class A { + constructor() { } - A.prototype.B = function () { + B() { return 42; - }; - return A; -})(); + } +} //# sourceMappingURL=es6-sourcemap-amd.js.map \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.js.map b/tests/baselines/reference/es6-sourcemap-amd.js.map index ef22eb4638c8b..779c13b129698 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.js.map +++ b/tests/baselines/reference/es6-sourcemap-amd.js.map @@ -1,2 +1,2 @@ //// [es6-sourcemap-amd.js.map] -{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,aAACA,GAARA;QAEIE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;IACLF,QAACA;AAADA,CAACA,AAXD,IAWC"} \ No newline at end of file +{"version":3,"file":"es6-sourcemap-amd.js","sourceRoot":"","sources":["es6-sourcemap-amd.ts"],"names":["A","A.constructor","A.B"],"mappings":"AACA;IAEIA;IAGAC,CAACA;IAEMD,CAACA;QAEJE,MAAMA,CAACA,EAAEA,CAACA;IACdA,CAACA;AACLF,CAACA;AAAA"} \ No newline at end of file diff --git a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt index bcfc33d04055c..179dd79ba1700 100644 --- a/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt +++ b/tests/baselines/reference/es6-sourcemap-amd.sourcemap.txt @@ -8,14 +8,14 @@ sources: es6-sourcemap-amd.ts emittedFile:tests/cases/compiler/es6-sourcemap-amd.js sourceFile:es6-sourcemap-amd.ts ------------------------------------------------------------------- ->>>var A = (function () { +>>>class A { 1 > -2 >^^^^^^^^^^^^^^^^^^^-> +2 >^^^^^^^^^^^^^^^^^^^^-> 1 > > 1 >Emitted(1, 1) Source(2, 1) + SourceIndex(0) --- ->>> function A() { +>>> constructor() { 1->^^^^ 2 > ^^-> 1->class A @@ -26,7 +26,7 @@ sourceFile:es6-sourcemap-amd.ts >>> } 1->^^^^ 2 > ^ -3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +3 > ^^^^^-> 1->constructor () > { > @@ -35,81 +35,57 @@ sourceFile:es6-sourcemap-amd.ts 1->Emitted(3, 5) Source(7, 5) + SourceIndex(0) name (A.constructor) 2 >Emitted(3, 6) Source(7, 6) + SourceIndex(0) name (A.constructor) --- ->>> A.prototype.B = function () { +>>> B() { 1->^^^^ -2 > ^^^^^^^^^^^^^ -3 > ^^^ +2 > ^ +3 > ^^^^^^^^^^^^^^-> 1-> > > public 2 > B -3 > 1->Emitted(4, 5) Source(9, 12) + SourceIndex(0) name (A) -2 >Emitted(4, 18) Source(9, 13) + SourceIndex(0) name (A) -3 >Emitted(4, 21) Source(9, 5) + SourceIndex(0) name (A) +2 >Emitted(4, 6) Source(9, 13) + SourceIndex(0) name (A) --- >>> return 42; -1 >^^^^^^^^ +1->^^^^^^^^ 2 > ^^^^^^ 3 > ^ 4 > ^^ 5 > ^ -1 >public B() +1->() > { > 2 > return 3 > 4 > 42 5 > ; -1 >Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) +1->Emitted(5, 9) Source(11, 9) + SourceIndex(0) name (A.B) 2 >Emitted(5, 15) Source(11, 15) + SourceIndex(0) name (A.B) 3 >Emitted(5, 16) Source(11, 16) + SourceIndex(0) name (A.B) 4 >Emitted(5, 18) Source(11, 18) + SourceIndex(0) name (A.B) 5 >Emitted(5, 19) Source(11, 19) + SourceIndex(0) name (A.B) --- ->>> }; +>>> } 1 >^^^^ 2 > ^ -3 > ^^^^^^^^^-> 1 > > 2 > } 1 >Emitted(6, 5) Source(12, 5) + SourceIndex(0) name (A.B) 2 >Emitted(6, 6) Source(12, 6) + SourceIndex(0) name (A.B) --- ->>> return A; -1->^^^^ -2 > ^^^^^^^^ -1-> - > -2 > } -1->Emitted(7, 5) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(7, 13) Source(13, 2) + SourceIndex(0) name (A) ---- ->>>})(); +>>>} 1 > 2 >^ -3 > -4 > ^^^^ -5 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> -1 > +3 > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1 > + > 2 >} -3 > -4 > class A - > { - > constructor () - > { - > - > } - > - > public B() - > { - > return 42; - > } - > } -1 >Emitted(8, 1) Source(13, 1) + SourceIndex(0) name (A) -2 >Emitted(8, 2) Source(13, 2) + SourceIndex(0) name (A) -3 >Emitted(8, 2) Source(2, 1) + SourceIndex(0) -4 >Emitted(8, 6) Source(13, 2) + SourceIndex(0) +1 >Emitted(7, 1) Source(13, 1) + SourceIndex(0) name (A) +2 >Emitted(7, 2) Source(13, 2) + SourceIndex(0) name (A) --- ->>>//# sourceMappingURL=es6-sourcemap-amd.js.map \ No newline at end of file +>>>//# sourceMappingURL=es6-sourcemap-amd.js.map1-> +2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-> +1-> +1->Emitted(8, 1) Source(13, 2) + SourceIndex(0) +--- \ No newline at end of file diff --git a/tests/baselines/reference/for-of14.js b/tests/baselines/reference/for-of14.js index 65ac7119fb610..958e621c8aa5b 100644 --- a/tests/baselines/reference/for-of14.js +++ b/tests/baselines/reference/for-of14.js @@ -12,11 +12,8 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should fail because the iterator is not iterable -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return ""; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of15.js b/tests/baselines/reference/for-of15.js index 74e34c2b2ae0c..2b4846ec8bef5 100644 --- a/tests/baselines/reference/for-of15.js +++ b/tests/baselines/reference/for-of15.js @@ -15,14 +15,11 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should fail -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return ""; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of16.js b/tests/baselines/reference/for-of16.js index 526dc277be7c1..1cdf72c26ac03 100644 --- a/tests/baselines/reference/for-of16.js +++ b/tests/baselines/reference/for-of16.js @@ -12,11 +12,8 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should fail -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of17.js b/tests/baselines/reference/for-of17.js index 268ead7ee18da..3fb4fac91d603 100644 --- a/tests/baselines/reference/for-of17.js +++ b/tests/baselines/reference/for-of17.js @@ -18,17 +18,14 @@ class NumberIterator { var v; for (v of new NumberIterator) { } // Should succeed -var NumberIterator = (function () { - function NumberIterator() { - } - NumberIterator.prototype.next = function () { +class NumberIterator { + next() { return { value: 0, done: false }; - }; - NumberIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return NumberIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of18.js b/tests/baselines/reference/for-of18.js index 3be876409dc4f..ae3a9e130f003 100644 --- a/tests/baselines/reference/for-of18.js +++ b/tests/baselines/reference/for-of18.js @@ -18,17 +18,14 @@ class StringIterator { var v; for (v of new StringIterator) { } // Should succeed -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return { value: "", done: false }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of19.js b/tests/baselines/reference/for-of19.js index eefb9339f18bd..d0f95caa1e27d 100644 --- a/tests/baselines/reference/for-of19.js +++ b/tests/baselines/reference/for-of19.js @@ -20,22 +20,16 @@ class FooIterator { for (var v of new FooIterator) { v; } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of20.js b/tests/baselines/reference/for-of20.js index 39b1081954be7..c098abd2f73a0 100644 --- a/tests/baselines/reference/for-of20.js +++ b/tests/baselines/reference/for-of20.js @@ -20,22 +20,16 @@ class FooIterator { for (let v of new FooIterator) { v; } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of21.js b/tests/baselines/reference/for-of21.js index 5deaad3c2d8f6..27da28e3b4f40 100644 --- a/tests/baselines/reference/for-of21.js +++ b/tests/baselines/reference/for-of21.js @@ -20,22 +20,16 @@ class FooIterator { for (const v of new FooIterator) { v; } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of22.js b/tests/baselines/reference/for-of22.js index d38accb6cd818..886e8dba7c33d 100644 --- a/tests/baselines/reference/for-of22.js +++ b/tests/baselines/reference/for-of22.js @@ -21,22 +21,16 @@ class FooIterator { v; for (var v of new FooIterator) { } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of23.js b/tests/baselines/reference/for-of23.js index 87bb1fd428d29..f5649128c115c 100644 --- a/tests/baselines/reference/for-of23.js +++ b/tests/baselines/reference/for-of23.js @@ -20,22 +20,16 @@ class FooIterator { for (const v of new FooIterator) { const v = 0; // new scope } -var Foo = (function () { - function Foo() { - } - return Foo; -})(); -var FooIterator = (function () { - function FooIterator() { - } - FooIterator.prototype.next = function () { +class Foo { +} +class FooIterator { + next() { return { value: new Foo, done: false }; - }; - FooIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return FooIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of25.js b/tests/baselines/reference/for-of25.js index 86c175f861e8e..2c85a4dc2fd34 100644 --- a/tests/baselines/reference/for-of25.js +++ b/tests/baselines/reference/for-of25.js @@ -12,11 +12,8 @@ class StringIterator { var x; for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return x; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of26.js b/tests/baselines/reference/for-of26.js index edb6b4c38b264..e048caf1006d5 100644 --- a/tests/baselines/reference/for-of26.js +++ b/tests/baselines/reference/for-of26.js @@ -15,14 +15,11 @@ class StringIterator { var x; for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return x; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of27.js b/tests/baselines/reference/for-of27.js index 379b95c5b09d7..8b44ca03ef455 100644 --- a/tests/baselines/reference/for-of27.js +++ b/tests/baselines/reference/for-of27.js @@ -8,8 +8,5 @@ class StringIterator { //// [for-of27.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - return StringIterator; -})(); +class StringIterator { +} diff --git a/tests/baselines/reference/for-of28.js b/tests/baselines/reference/for-of28.js index 79b1590e12fb1..69c8ccab72798 100644 --- a/tests/baselines/reference/for-of28.js +++ b/tests/baselines/reference/for-of28.js @@ -11,11 +11,8 @@ class StringIterator { //// [for-of28.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of30.js b/tests/baselines/reference/for-of30.js index 759c7823e63e1..0ed6caaf81e61 100644 --- a/tests/baselines/reference/for-of30.js +++ b/tests/baselines/reference/for-of30.js @@ -19,18 +19,17 @@ class StringIterator { //// [for-of30.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { +class StringIterator { + constructor() { this.return = 0; } - StringIterator.prototype.next = function () { + next() { return { done: false, value: "" }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of31.js b/tests/baselines/reference/for-of31.js index 6773c8a3452ca..d38c1fa017d26 100644 --- a/tests/baselines/reference/for-of31.js +++ b/tests/baselines/reference/for-of31.js @@ -17,17 +17,14 @@ class StringIterator { //// [for-of31.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return { // no done property value: "" }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of33.js b/tests/baselines/reference/for-of33.js index f3a75eec13701..66097f777c8c2 100644 --- a/tests/baselines/reference/for-of33.js +++ b/tests/baselines/reference/for-of33.js @@ -10,11 +10,8 @@ class StringIterator { //// [for-of33.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype[Symbol.iterator] = function () { +class StringIterator { + [Symbol.iterator]() { return v; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of34.js b/tests/baselines/reference/for-of34.js index 521b4f3c2a4aa..568a9f73535f9 100644 --- a/tests/baselines/reference/for-of34.js +++ b/tests/baselines/reference/for-of34.js @@ -14,14 +14,11 @@ class StringIterator { //// [for-of34.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return v; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/for-of35.js b/tests/baselines/reference/for-of35.js index cb6dc0e532fc5..a157d5e2e8eb1 100644 --- a/tests/baselines/reference/for-of35.js +++ b/tests/baselines/reference/for-of35.js @@ -17,17 +17,14 @@ class StringIterator { //// [for-of35.js] for (var v of new StringIterator) { } -var StringIterator = (function () { - function StringIterator() { - } - StringIterator.prototype.next = function () { +class StringIterator { + next() { return { done: true, value: v }; - }; - StringIterator.prototype[Symbol.iterator] = function () { + } + [Symbol.iterator]() { return this; - }; - return StringIterator; -})(); + } +} diff --git a/tests/baselines/reference/letDeclarations-scopes.js b/tests/baselines/reference/letDeclarations-scopes.js index fc7218079940d..d0489820d0b90 100644 --- a/tests/baselines/reference/letDeclarations-scopes.js +++ b/tests/baselines/reference/letDeclarations-scopes.js @@ -259,30 +259,25 @@ var m; lable: let l2 = 0; })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { let l = 0; n = l; } - C.prototype.method = function () { + method() { let l = 0; n = l; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - let l = 0; - n = l; - return n; - }, - set: function (value) { - let l = 0; - n = l; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + let l = 0; + n = l; + return n; + } + set v(value) { + let l = 0; + n = l; + } +} // object literals var o = { f() { diff --git a/tests/baselines/reference/letDeclarations-validContexts.js b/tests/baselines/reference/letDeclarations-validContexts.js index f6d404135f695..b11a19223836d 100644 --- a/tests/baselines/reference/letDeclarations-validContexts.js +++ b/tests/baselines/reference/letDeclarations-validContexts.js @@ -221,26 +221,21 @@ var m; } })(m || (m = {})); // methods -var C = (function () { - function C() { +class C { + constructor() { let l24 = 0; } - C.prototype.method = function () { + method() { let l25 = 0; - }; - Object.defineProperty(C.prototype, "v", { - get: function () { - let l26 = 0; - return l26; - }, - set: function (value) { - let l27 = value; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + } + get v() { + let l26 = 0; + return l26; + } + set v(value) { + let l27 = value; + } +} // object literals var o = { f() { diff --git a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt new file mode 100644 index 0000000000000..d109b0480854b --- /dev/null +++ b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.errors.txt @@ -0,0 +1,25 @@ +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(4,16): error TS1100: Invalid use of 'arguments' in strict mode. +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(5,17): error TS1100: Invalid use of 'eval' in strict mode. +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS1100: Invalid use of 'arguments' in strict mode. +tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts(6,9): error TS2322: Type 'string' is not assignable to type 'IArguments'. + Property 'callee' is missing in type 'String'. + + +==== tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts (4 errors) ==== + class C { + interface = 10; + public implements() { } + public foo(arguments: any) { } + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + private bar(eval:any) { + ~~~~ +!!! error TS1100: Invalid use of 'eval' in strict mode. + arguments = "hello"; + ~~~~~~~~~ +!!! error TS1100: Invalid use of 'arguments' in strict mode. + ~~~~~~~~~ +!!! error TS2322: Type 'string' is not assignable to type 'IArguments'. +!!! error TS2322: Property 'callee' is missing in type 'String'. + } + } \ No newline at end of file diff --git a/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.js b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.js new file mode 100644 index 0000000000000..2a8d75dde60aa --- /dev/null +++ b/tests/baselines/reference/parseClassDeclarationInStrictModeByDefaultInES6.js @@ -0,0 +1,23 @@ +//// [parseClassDeclarationInStrictModeByDefaultInES6.ts] +class C { + interface = 10; + public implements() { } + public foo(arguments: any) { } + private bar(eval:any) { + arguments = "hello"; + } +} + +//// [parseClassDeclarationInStrictModeByDefaultInES6.js] +class C { + constructor() { + this.interface = 10; + } + implements() { + } + foo(arguments) { + } + bar(eval) { + arguments = "hello"; + } +} diff --git a/tests/baselines/reference/parserComputedPropertyName10.js b/tests/baselines/reference/parserComputedPropertyName10.js index c00d3292f7e48..eba480ba81088 100644 --- a/tests/baselines/reference/parserComputedPropertyName10.js +++ b/tests/baselines/reference/parserComputedPropertyName10.js @@ -4,9 +4,8 @@ class C { } //// [parserComputedPropertyName10.js] -var C = (function () { - function C() { +class C { + constructor() { this[e] = 1; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName11.js b/tests/baselines/reference/parserComputedPropertyName11.js index 1b9575184f257..dc63d6385d848 100644 --- a/tests/baselines/reference/parserComputedPropertyName11.js +++ b/tests/baselines/reference/parserComputedPropertyName11.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName11.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName12.js b/tests/baselines/reference/parserComputedPropertyName12.js index 96e62b626e759..71cf1d352f48a 100644 --- a/tests/baselines/reference/parserComputedPropertyName12.js +++ b/tests/baselines/reference/parserComputedPropertyName12.js @@ -4,10 +4,7 @@ class C { } //// [parserComputedPropertyName12.js] -var C = (function () { - function C() { +class C { + [e]() { } - C.prototype[e] = function () { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName24.js b/tests/baselines/reference/parserComputedPropertyName24.js index 0b9467fb26d26..8fc0a5be3a50d 100644 --- a/tests/baselines/reference/parserComputedPropertyName24.js +++ b/tests/baselines/reference/parserComputedPropertyName24.js @@ -4,14 +4,7 @@ class C { } //// [parserComputedPropertyName24.js] -var C = (function () { - function C() { +class C { + set [e](v) { } - Object.defineProperty(C.prototype, e, { - set: function (v) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName25.js b/tests/baselines/reference/parserComputedPropertyName25.js index a00cec2e6dd72..47670fe14b8dc 100644 --- a/tests/baselines/reference/parserComputedPropertyName25.js +++ b/tests/baselines/reference/parserComputedPropertyName25.js @@ -6,10 +6,9 @@ class C { } //// [parserComputedPropertyName25.js] -var C = (function () { - function C() { +class C { + constructor() { // No ASI this[e] = 0[e2] = 1; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName27.js b/tests/baselines/reference/parserComputedPropertyName27.js index 03b156af840a3..f872e95e7e659 100644 --- a/tests/baselines/reference/parserComputedPropertyName27.js +++ b/tests/baselines/reference/parserComputedPropertyName27.js @@ -6,10 +6,9 @@ class C { } //// [parserComputedPropertyName27.js] -var C = (function () { - function C() { +class C { + constructor() { // No ASI this[e] = 0[e2]; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName28.js b/tests/baselines/reference/parserComputedPropertyName28.js index 60fb25dfa209e..998f60db91462 100644 --- a/tests/baselines/reference/parserComputedPropertyName28.js +++ b/tests/baselines/reference/parserComputedPropertyName28.js @@ -5,9 +5,8 @@ class C { } //// [parserComputedPropertyName28.js] -var C = (function () { - function C() { +class C { + constructor() { this[e] = 0; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName29.js b/tests/baselines/reference/parserComputedPropertyName29.js index 05ced020aff21..a100cbf17915c 100644 --- a/tests/baselines/reference/parserComputedPropertyName29.js +++ b/tests/baselines/reference/parserComputedPropertyName29.js @@ -6,10 +6,9 @@ class C { } //// [parserComputedPropertyName29.js] -var C = (function () { - function C() { +class C { + constructor() { // yes ASI this[e] = id++; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName31.js b/tests/baselines/reference/parserComputedPropertyName31.js index 2a07155a2f025..cee09fb0ab7bb 100644 --- a/tests/baselines/reference/parserComputedPropertyName31.js +++ b/tests/baselines/reference/parserComputedPropertyName31.js @@ -6,8 +6,5 @@ class C { } //// [parserComputedPropertyName31.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName33.js b/tests/baselines/reference/parserComputedPropertyName33.js index 1cc06c06780e7..64239bc1284a1 100644 --- a/tests/baselines/reference/parserComputedPropertyName33.js +++ b/tests/baselines/reference/parserComputedPropertyName33.js @@ -6,12 +6,11 @@ class C { } //// [parserComputedPropertyName33.js] -var C = (function () { - function C() { +class C { + constructor() { // No ASI this[e] = 0[e2](); } - return C; -})(); +} { } diff --git a/tests/baselines/reference/parserComputedPropertyName36.errors.txt b/tests/baselines/reference/parserComputedPropertyName36.errors.txt index 07e937b3b42a6..8c647be13c9d6 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName36.errors.txt @@ -1,12 +1,15 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS2304: Cannot find name 'public'. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,6): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts(2,14): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName36.ts (3 errors) ==== class C { [public ]: string; - ~~~~~~~~~ -!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol. ~~~~~~ -!!! error TS2304: Cannot find name 'public'. +!!! error TS1109: Expression expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. } \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName36.js b/tests/baselines/reference/parserComputedPropertyName36.js index 264a351207581..fd6f376ef2b1c 100644 --- a/tests/baselines/reference/parserComputedPropertyName36.js +++ b/tests/baselines/reference/parserComputedPropertyName36.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName36.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName38.errors.txt b/tests/baselines/reference/parserComputedPropertyName38.errors.txt index 4322abf44edaf..28daf32274860 100644 --- a/tests/baselines/reference/parserComputedPropertyName38.errors.txt +++ b/tests/baselines/reference/parserComputedPropertyName38.errors.txt @@ -1,9 +1,21 @@ -tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,6): error TS2304: Cannot find name 'public'. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,6): error TS1109: Expression expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,12): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,13): error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(2,16): error TS1005: '=>' expected. +tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts(3,1): error TS1128: Declaration or statement expected. -==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (1 errors) ==== +==== tests/cases/conformance/parser/ecmascript6/ComputedPropertyNames/parserComputedPropertyName38.ts (5 errors) ==== class C { [public]() { } ~~~~~~ -!!! error TS2304: Cannot find name 'public'. - } \ No newline at end of file +!!! error TS1109: Expression expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1068: Unexpected token. A constructor, method, accessor, or property was expected. + ~ +!!! error TS1005: '=>' expected. + } + ~ +!!! error TS1128: Declaration or statement expected. \ No newline at end of file diff --git a/tests/baselines/reference/parserComputedPropertyName38.js b/tests/baselines/reference/parserComputedPropertyName38.js index 487ff4078fde4..e5c9512ad2d31 100644 --- a/tests/baselines/reference/parserComputedPropertyName38.js +++ b/tests/baselines/reference/parserComputedPropertyName38.js @@ -4,10 +4,7 @@ class C { } //// [parserComputedPropertyName38.js] -var C = (function () { - function C() { - } - C.prototype[public] = function () { - }; - return C; -})(); +class C { +} +(() => { +}); diff --git a/tests/baselines/reference/parserComputedPropertyName39.js b/tests/baselines/reference/parserComputedPropertyName39.js index c37312f003421..cee81ccc3d0f3 100644 --- a/tests/baselines/reference/parserComputedPropertyName39.js +++ b/tests/baselines/reference/parserComputedPropertyName39.js @@ -6,10 +6,7 @@ class C { //// [parserComputedPropertyName39.js] "use strict"; -var C = (function () { - function C() { - } - return C; -})(); +class C { +} (() => { }); diff --git a/tests/baselines/reference/parserComputedPropertyName40.js b/tests/baselines/reference/parserComputedPropertyName40.js index 5f6381360fc2f..417e37067d1b1 100644 --- a/tests/baselines/reference/parserComputedPropertyName40.js +++ b/tests/baselines/reference/parserComputedPropertyName40.js @@ -4,10 +4,7 @@ class C { } //// [parserComputedPropertyName40.js] -var C = (function () { - function C() { +class C { + [a ? "" : ""]() { } - C.prototype[a ? "" : ""] = function () { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/parserComputedPropertyName7.js b/tests/baselines/reference/parserComputedPropertyName7.js index 70ed8b7b0738e..aa18db09bc682 100644 --- a/tests/baselines/reference/parserComputedPropertyName7.js +++ b/tests/baselines/reference/parserComputedPropertyName7.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName7.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName8.js b/tests/baselines/reference/parserComputedPropertyName8.js index 4b79c45966301..bab7c3198bd77 100644 --- a/tests/baselines/reference/parserComputedPropertyName8.js +++ b/tests/baselines/reference/parserComputedPropertyName8.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName8.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserComputedPropertyName9.js b/tests/baselines/reference/parserComputedPropertyName9.js index 4b62cc0ecd968..3ba028a4a1c26 100644 --- a/tests/baselines/reference/parserComputedPropertyName9.js +++ b/tests/baselines/reference/parserComputedPropertyName9.js @@ -4,8 +4,5 @@ class C { } //// [parserComputedPropertyName9.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSuperExpression1.js b/tests/baselines/reference/parserSuperExpression1.js index d0d7f4dcd5261..0d312f79104e1 100644 --- a/tests/baselines/reference/parserSuperExpression1.js +++ b/tests/baselines/reference/parserSuperExpression1.js @@ -18,7 +18,7 @@ var C = (function () { function C() { } C.prototype.foo = function () { - super.foo.call(this); + _super.foo.call(this); }; return C; })(); @@ -30,7 +30,7 @@ var M1; function C() { } C.prototype.foo = function () { - super.foo.call(this); + _super.foo.call(this); }; return C; })(); diff --git a/tests/baselines/reference/parserSuperExpression2.js b/tests/baselines/reference/parserSuperExpression2.js index 8d0c6cf369839..7a77c28ef5240 100644 --- a/tests/baselines/reference/parserSuperExpression2.js +++ b/tests/baselines/reference/parserSuperExpression2.js @@ -10,7 +10,7 @@ var C = (function () { function C() { } C.prototype.M = function () { - super..call(this, 0); + _super..call(this, 0); }; return C; })(); diff --git a/tests/baselines/reference/parserSuperExpression4.js b/tests/baselines/reference/parserSuperExpression4.js index a36981416df43..46ffc65f57cd5 100644 --- a/tests/baselines/reference/parserSuperExpression4.js +++ b/tests/baselines/reference/parserSuperExpression4.js @@ -18,7 +18,7 @@ var C = (function () { function C() { } C.prototype.foo = function () { - super.foo = 1; + _super.foo = 1; }; return C; })(); @@ -30,7 +30,7 @@ var M1; function C() { } C.prototype.foo = function () { - super.foo = 1; + _super.foo = 1; }; return C; })(); diff --git a/tests/baselines/reference/parserSymbolIndexer2.js b/tests/baselines/reference/parserSymbolIndexer2.js index 563614e1c8cf7..4bfe400de53a5 100644 --- a/tests/baselines/reference/parserSymbolIndexer2.js +++ b/tests/baselines/reference/parserSymbolIndexer2.js @@ -4,8 +4,5 @@ class C { } //// [parserSymbolIndexer2.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSymbolIndexer3.js b/tests/baselines/reference/parserSymbolIndexer3.js index 917945193aee0..36247ea2a139a 100644 --- a/tests/baselines/reference/parserSymbolIndexer3.js +++ b/tests/baselines/reference/parserSymbolIndexer3.js @@ -4,8 +4,5 @@ class C { } //// [parserSymbolIndexer3.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSymbolProperty5.js b/tests/baselines/reference/parserSymbolProperty5.js index 922e1fb0323ba..a8b1d564fa800 100644 --- a/tests/baselines/reference/parserSymbolProperty5.js +++ b/tests/baselines/reference/parserSymbolProperty5.js @@ -4,8 +4,5 @@ class C { } //// [parserSymbolProperty5.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/parserSymbolProperty6.js b/tests/baselines/reference/parserSymbolProperty6.js index cbc06cd295173..d2aa55fe0859a 100644 --- a/tests/baselines/reference/parserSymbolProperty6.js +++ b/tests/baselines/reference/parserSymbolProperty6.js @@ -4,9 +4,8 @@ class C { } //// [parserSymbolProperty6.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol.toStringTag] = ""; } - return C; -})(); +} diff --git a/tests/baselines/reference/parserSymbolProperty7.js b/tests/baselines/reference/parserSymbolProperty7.js index 9d34b9e3bcef2..a3061ee1b5867 100644 --- a/tests/baselines/reference/parserSymbolProperty7.js +++ b/tests/baselines/reference/parserSymbolProperty7.js @@ -4,10 +4,7 @@ class C { } //// [parserSymbolProperty7.js] -var C = (function () { - function C() { +class C { + [Symbol.toStringTag]() { } - C.prototype[Symbol.toStringTag] = function () { - }; - return C; -})(); +} diff --git a/tests/baselines/reference/super.js b/tests/baselines/reference/super.js index 5c3102cd877ec..453eb820ddbee 100644 --- a/tests/baselines/reference/super.js +++ b/tests/baselines/reference/super.js @@ -80,7 +80,7 @@ var Base2 = (function () { function Base2() { } Base2.prototype.foo = function () { - super.foo.call(this); + _super.foo.call(this); }; return Base2; })(); diff --git a/tests/baselines/reference/super1.js b/tests/baselines/reference/super1.js index acc5b4072f5de..ab982aa8fdf0c 100644 --- a/tests/baselines/reference/super1.js +++ b/tests/baselines/reference/super1.js @@ -166,7 +166,7 @@ var Base4; function Sub4E() { } Sub4E.prototype.x = function () { - return super.x.call(this); + return _super.x.call(this); }; return Sub4E; })(); diff --git a/tests/baselines/reference/superAccess2.js b/tests/baselines/reference/superAccess2.js index cd3d9c63e4140..259afb1af0f5a 100644 --- a/tests/baselines/reference/superAccess2.js +++ b/tests/baselines/reference/superAccess2.js @@ -64,6 +64,6 @@ var Q = (function (_super) { _super.x.call(this); // error _super.y.call(this); }; - Q.yy = super.; // error for static initializer accessing super + Q.yy = _super.; // error for static initializer accessing super return Q; })(P); diff --git a/tests/baselines/reference/superErrors.js b/tests/baselines/reference/superErrors.js index 2dc2db1a3d422..2b1a508261710 100644 --- a/tests/baselines/reference/superErrors.js +++ b/tests/baselines/reference/superErrors.js @@ -60,14 +60,14 @@ var __extends = this.__extends || function (d, b) { }; function foo() { // super in a non class context - var x = super.; + var x = _super.; var y = function () { - return super.; + return _super.; }; var z = function () { return function () { return function () { - return super.; + return _super.; }; }; }; @@ -88,18 +88,18 @@ var RegisteredUser = (function (_super) { this.name = "Frank"; // super call in an inner function in a constructor function inner() { - super.sayHello.call(this); + _super.sayHello.call(this); } // super call in a lambda in an inner function in a constructor function inner2() { var x = function () { - return super.sayHello.call(this); + return _super.sayHello.call(this); }; } // super call in a lambda in a function expression in a constructor (function () { return function () { - return super.; + return _super.; }; })(); } @@ -109,13 +109,13 @@ var RegisteredUser = (function (_super) { // super call in a lambda in an inner function in a method function inner() { var x = function () { - return super.sayHello.call(this); + return _super.sayHello.call(this); }; } // super call in a lambda in a function expression in a constructor (function () { return function () { - return super.; + return _super.; }; })(); }; diff --git a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js index 48ae609cdc604..c4ced2a9dcc7d 100644 --- a/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js +++ b/tests/baselines/reference/super_inside-object-literal-getters-and-setters.js @@ -39,13 +39,13 @@ var ObjectLiteral; var ThisInObjectLiteral = { _foo: '1', get foo() { - return super._foo; + return _super._foo; }, set foo(value) { - super._foo = value; + _super._foo = value; }, test: function () { - return super._foo; + return _super._foo; } }; })(ObjectLiteral || (ObjectLiteral = {})); @@ -65,7 +65,7 @@ var SuperObjectTest = (function (_super) { SuperObjectTest.prototype.testing = function () { var test = { get F() { - return super.test.call(this); + return _super.test.call(this); } }; }; diff --git a/tests/baselines/reference/symbolDeclarationEmit1.js b/tests/baselines/reference/symbolDeclarationEmit1.js index 16d208db5eb86..7c3b39b9d86f4 100644 --- a/tests/baselines/reference/symbolDeclarationEmit1.js +++ b/tests/baselines/reference/symbolDeclarationEmit1.js @@ -4,11 +4,8 @@ class C { } //// [symbolDeclarationEmit1.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} //// [symbolDeclarationEmit1.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit11.js b/tests/baselines/reference/symbolDeclarationEmit11.js index c9c819eefa266..599f7393f4bc2 100644 --- a/tests/baselines/reference/symbolDeclarationEmit11.js +++ b/tests/baselines/reference/symbolDeclarationEmit11.js @@ -7,23 +7,16 @@ class C { } //// [symbolDeclarationEmit11.js] -var C = (function () { - function C() { +class C { + static [Symbol.toPrimitive]() { } - C[Symbol.toPrimitive] = function () { - }; - Object.defineProperty(C, Symbol.isRegExp, { - get: function () { - return ""; - }, - set: function (x) { - }, - enumerable: true, - configurable: true - }); - C[Symbol.iterator] = 0; - return C; -})(); + static get [Symbol.isRegExp]() { + return ""; + } + static set [Symbol.isRegExp](x) { + } +} +C[Symbol.iterator] = 0; //// [symbolDeclarationEmit11.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit12.js b/tests/baselines/reference/symbolDeclarationEmit12.js index 49ff8b3597672..9a75f6d573cb8 100644 --- a/tests/baselines/reference/symbolDeclarationEmit12.js +++ b/tests/baselines/reference/symbolDeclarationEmit12.js @@ -15,24 +15,16 @@ module M { //// [symbolDeclarationEmit12.js] var M; (function (M) { - var C = (function () { - function C() { + export class C { + [Symbol.toPrimitive](x) { } - C.prototype[Symbol.toPrimitive] = function (x) { - }; - C.prototype[Symbol.isConcatSpreadable] = function () { + [Symbol.isConcatSpreadable]() { return undefined; - }; - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return undefined; - }, - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; - })(); - M.C = C; + } + get [Symbol.isRegExp]() { + return undefined; + } + set [Symbol.isRegExp](x) { + } + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolDeclarationEmit13.js b/tests/baselines/reference/symbolDeclarationEmit13.js index 51b6edcece5ee..f48a918a6f2d7 100644 --- a/tests/baselines/reference/symbolDeclarationEmit13.js +++ b/tests/baselines/reference/symbolDeclarationEmit13.js @@ -5,24 +5,13 @@ class C { } //// [symbolDeclarationEmit13.js] -var C = (function () { - function C() { +class C { + get [Symbol.isRegExp]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, Symbol.toStringTag, { - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + set [Symbol.toStringTag](x) { + } +} //// [symbolDeclarationEmit13.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit14.js b/tests/baselines/reference/symbolDeclarationEmit14.js index d81bc329927d0..6197ffa2b4fc0 100644 --- a/tests/baselines/reference/symbolDeclarationEmit14.js +++ b/tests/baselines/reference/symbolDeclarationEmit14.js @@ -5,25 +5,14 @@ class C { } //// [symbolDeclarationEmit14.js] -var C = (function () { - function C() { +class C { + get [Symbol.isRegExp]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, Symbol.toStringTag, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get [Symbol.toStringTag]() { + return ""; + } +} //// [symbolDeclarationEmit14.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit2.js b/tests/baselines/reference/symbolDeclarationEmit2.js index 2112f9e774874..5558bebc64efa 100644 --- a/tests/baselines/reference/symbolDeclarationEmit2.js +++ b/tests/baselines/reference/symbolDeclarationEmit2.js @@ -4,12 +4,11 @@ class C { } //// [symbolDeclarationEmit2.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol.isRegExp] = ""; } - return C; -})(); +} //// [symbolDeclarationEmit2.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit3.js b/tests/baselines/reference/symbolDeclarationEmit3.js index 6d06c09bd692e..6f513b053c7c4 100644 --- a/tests/baselines/reference/symbolDeclarationEmit3.js +++ b/tests/baselines/reference/symbolDeclarationEmit3.js @@ -6,13 +6,10 @@ class C { } //// [symbolDeclarationEmit3.js] -var C = (function () { - function C() { +class C { + [Symbol.isRegExp](x) { } - C.prototype[Symbol.isRegExp] = function (x) { - }; - return C; -})(); +} //// [symbolDeclarationEmit3.d.ts] diff --git a/tests/baselines/reference/symbolDeclarationEmit4.js b/tests/baselines/reference/symbolDeclarationEmit4.js index cd3fc53a5bb9b..14f50a03ee740 100644 --- a/tests/baselines/reference/symbolDeclarationEmit4.js +++ b/tests/baselines/reference/symbolDeclarationEmit4.js @@ -5,20 +5,13 @@ class C { } //// [symbolDeclarationEmit4.js] -var C = (function () { - function C() { +class C { + get [Symbol.isRegExp]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.isRegExp, { - get: function () { - return ""; - }, - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + set [Symbol.isRegExp](x) { + } +} //// [symbolDeclarationEmit4.d.ts] diff --git a/tests/baselines/reference/symbolProperty10.js b/tests/baselines/reference/symbolProperty10.js index 5b4e44f11abd8..74bcf886461e5 100644 --- a/tests/baselines/reference/symbolProperty10.js +++ b/tests/baselines/reference/symbolProperty10.js @@ -11,11 +11,8 @@ i = new C; var c: C = i; //// [symbolProperty10.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/symbolProperty11.js b/tests/baselines/reference/symbolProperty11.js index 83a380c79e7c3..97fa4fc992f8e 100644 --- a/tests/baselines/reference/symbolProperty11.js +++ b/tests/baselines/reference/symbolProperty11.js @@ -9,11 +9,8 @@ i = new C; var c: C = i; //// [symbolProperty11.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/symbolProperty12.js b/tests/baselines/reference/symbolProperty12.js index 9f63f86bc182b..474ec4a0ffad8 100644 --- a/tests/baselines/reference/symbolProperty12.js +++ b/tests/baselines/reference/symbolProperty12.js @@ -11,11 +11,8 @@ i = new C; var c: C = i; //// [symbolProperty12.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/symbolProperty13.js b/tests/baselines/reference/symbolProperty13.js index 1cf24a49c7e2c..d7620d01159dc 100644 --- a/tests/baselines/reference/symbolProperty13.js +++ b/tests/baselines/reference/symbolProperty13.js @@ -17,11 +17,8 @@ var i: I; bar(i); //// [symbolProperty13.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty14.js b/tests/baselines/reference/symbolProperty14.js index 0283cb01b792a..716bc68b43029 100644 --- a/tests/baselines/reference/symbolProperty14.js +++ b/tests/baselines/reference/symbolProperty14.js @@ -17,11 +17,8 @@ var i: I; bar(i); //// [symbolProperty14.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty15.js b/tests/baselines/reference/symbolProperty15.js index 0c1980370937a..dec61964252ce 100644 --- a/tests/baselines/reference/symbolProperty15.js +++ b/tests/baselines/reference/symbolProperty15.js @@ -15,11 +15,8 @@ var i: I; bar(i); //// [symbolProperty15.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty16.js b/tests/baselines/reference/symbolProperty16.js index 1a1f3f857af97..1382d913104f9 100644 --- a/tests/baselines/reference/symbolProperty16.js +++ b/tests/baselines/reference/symbolProperty16.js @@ -17,11 +17,8 @@ var i: I; bar(i); //// [symbolProperty16.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} foo(new C); var i; bar(i); diff --git a/tests/baselines/reference/symbolProperty23.js b/tests/baselines/reference/symbolProperty23.js index b3291ad34e8bc..3210f6dfed7d2 100644 --- a/tests/baselines/reference/symbolProperty23.js +++ b/tests/baselines/reference/symbolProperty23.js @@ -10,11 +10,8 @@ class C implements I { } //// [symbolProperty23.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.toPrimitive] = function () { +class C { + [Symbol.toPrimitive]() { return true; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty24.js b/tests/baselines/reference/symbolProperty24.js index b5d059dd29f1a..3d582d8025440 100644 --- a/tests/baselines/reference/symbolProperty24.js +++ b/tests/baselines/reference/symbolProperty24.js @@ -10,11 +10,8 @@ class C implements I { } //// [symbolProperty24.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.toPrimitive] = function () { +class C { + [Symbol.toPrimitive]() { return ""; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty25.js b/tests/baselines/reference/symbolProperty25.js index c932da1e3ebea..33c398a6c0ee4 100644 --- a/tests/baselines/reference/symbolProperty25.js +++ b/tests/baselines/reference/symbolProperty25.js @@ -10,11 +10,8 @@ class C implements I { } //// [symbolProperty25.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.toStringTag] = function () { +class C { + [Symbol.toStringTag]() { return ""; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty26.js b/tests/baselines/reference/symbolProperty26.js index 9e98027603d43..837ef5837b0ee 100644 --- a/tests/baselines/reference/symbolProperty26.js +++ b/tests/baselines/reference/symbolProperty26.js @@ -12,27 +12,13 @@ class C2 extends C1 { } //// [symbolProperty26.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return ""; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - C2.prototype[Symbol.toStringTag] = function () { +} +class C2 extends C1 { + [Symbol.toStringTag]() { return ""; - }; - return C2; -})(C1); + } +} diff --git a/tests/baselines/reference/symbolProperty27.js b/tests/baselines/reference/symbolProperty27.js index f19d05233cb28..d4eb6fcafa786 100644 --- a/tests/baselines/reference/symbolProperty27.js +++ b/tests/baselines/reference/symbolProperty27.js @@ -12,27 +12,13 @@ class C2 extends C1 { } //// [symbolProperty27.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return {}; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - C2.prototype[Symbol.toStringTag] = function () { +} +class C2 extends C1 { + [Symbol.toStringTag]() { return ""; - }; - return C2; -})(C1); + } +} diff --git a/tests/baselines/reference/symbolProperty28.js b/tests/baselines/reference/symbolProperty28.js index 57c826cb7ab1b..ed53a88f95716 100644 --- a/tests/baselines/reference/symbolProperty28.js +++ b/tests/baselines/reference/symbolProperty28.js @@ -11,28 +11,14 @@ var c: C2; var obj = c[Symbol.toStringTag]().x; //// [symbolProperty28.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - return C2; -})(C1); +} +class C2 extends C1 { +} var c; var obj = c[Symbol.toStringTag]().x; diff --git a/tests/baselines/reference/symbolProperty29.js b/tests/baselines/reference/symbolProperty29.js index da6afdc642062..759a775482689 100644 --- a/tests/baselines/reference/symbolProperty29.js +++ b/tests/baselines/reference/symbolProperty29.js @@ -7,13 +7,10 @@ class C1 { } //// [symbolProperty29.js] -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty30.js b/tests/baselines/reference/symbolProperty30.js index af151e0efd5c3..263fdc1041be5 100644 --- a/tests/baselines/reference/symbolProperty30.js +++ b/tests/baselines/reference/symbolProperty30.js @@ -7,13 +7,10 @@ class C1 { } //// [symbolProperty30.js] -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty31.js b/tests/baselines/reference/symbolProperty31.js index e8388225dd7f1..a9db50061b31b 100644 --- a/tests/baselines/reference/symbolProperty31.js +++ b/tests/baselines/reference/symbolProperty31.js @@ -9,26 +9,12 @@ class C2 extends C1 { } //// [symbolProperty31.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - return C2; -})(C1); +} +class C2 extends C1 { +} diff --git a/tests/baselines/reference/symbolProperty32.js b/tests/baselines/reference/symbolProperty32.js index b544c60da7e10..52db43bb9de8c 100644 --- a/tests/baselines/reference/symbolProperty32.js +++ b/tests/baselines/reference/symbolProperty32.js @@ -9,26 +9,12 @@ class C2 extends C1 { } //// [symbolProperty32.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function () { - function C1() { - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(); -var C2 = (function (_super) { - __extends(C2, _super); - function C2() { - _super.apply(this, arguments); } - return C2; -})(C1); +} +class C2 extends C1 { +} diff --git a/tests/baselines/reference/symbolProperty33.js b/tests/baselines/reference/symbolProperty33.js index 082c0fe7e656a..8a0e3f691b5ac 100644 --- a/tests/baselines/reference/symbolProperty33.js +++ b/tests/baselines/reference/symbolProperty33.js @@ -9,26 +9,12 @@ class C2 { } //// [symbolProperty33.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function (_super) { - __extends(C1, _super); - function C1() { - _super.apply(this, arguments); - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 extends C2 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(C2); -var C2 = (function () { - function C2() { } - return C2; -})(); +} +class C2 { +} diff --git a/tests/baselines/reference/symbolProperty34.js b/tests/baselines/reference/symbolProperty34.js index de7d722227b08..b8bcd54487f81 100644 --- a/tests/baselines/reference/symbolProperty34.js +++ b/tests/baselines/reference/symbolProperty34.js @@ -9,26 +9,12 @@ class C2 { } //// [symbolProperty34.js] -var __extends = this.__extends || function (d, b) { - for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; - function __() { this.constructor = d; } - __.prototype = b.prototype; - d.prototype = new __(); -}; -var C1 = (function (_super) { - __extends(C1, _super); - function C1() { - _super.apply(this, arguments); - } - C1.prototype[Symbol.toStringTag] = function () { +class C1 extends C2 { + [Symbol.toStringTag]() { return { x: "" }; - }; - return C1; -})(C2); -var C2 = (function () { - function C2() { } - return C2; -})(); +} +class C2 { +} diff --git a/tests/baselines/reference/symbolProperty39.js b/tests/baselines/reference/symbolProperty39.js index 18551d20c0b33..6454d4a983f49 100644 --- a/tests/baselines/reference/symbolProperty39.js +++ b/tests/baselines/reference/symbolProperty39.js @@ -11,14 +11,11 @@ class C { } //// [symbolProperty39.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.iterator] = function (x) { +class C { + [Symbol.iterator](x) { return undefined; - }; - C.prototype[Symbol.iterator] = function (x) { + } + [Symbol.iterator](x) { return undefined; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty40.js b/tests/baselines/reference/symbolProperty40.js index 15d8c5c6fba81..cf5a3c4396dc1 100644 --- a/tests/baselines/reference/symbolProperty40.js +++ b/tests/baselines/reference/symbolProperty40.js @@ -13,14 +13,11 @@ c[Symbol.iterator](0); //// [symbolProperty40.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.iterator] = function (x) { +class C { + [Symbol.iterator](x) { return undefined; - }; - return C; -})(); + } +} var c = new C; c[Symbol.iterator](""); c[Symbol.iterator](0); diff --git a/tests/baselines/reference/symbolProperty41.js b/tests/baselines/reference/symbolProperty41.js index d26b2c7682aee..fd9d58082b6c2 100644 --- a/tests/baselines/reference/symbolProperty41.js +++ b/tests/baselines/reference/symbolProperty41.js @@ -13,14 +13,11 @@ c[Symbol.iterator]("hello"); //// [symbolProperty41.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.iterator] = function (x) { +class C { + [Symbol.iterator](x) { return undefined; - }; - return C; -})(); + } +} var c = new C; c[Symbol.iterator](""); c[Symbol.iterator]("hello"); diff --git a/tests/baselines/reference/symbolProperty42.js b/tests/baselines/reference/symbolProperty42.js index 1990f54066c6c..082e862f0fcf1 100644 --- a/tests/baselines/reference/symbolProperty42.js +++ b/tests/baselines/reference/symbolProperty42.js @@ -8,11 +8,8 @@ class C { } //// [symbolProperty42.js] -var C = (function () { - function C() { - } - C.prototype[Symbol.iterator] = function (x) { +class C { + [Symbol.iterator](x) { return undefined; - }; - return C; -})(); + } +} diff --git a/tests/baselines/reference/symbolProperty43.js b/tests/baselines/reference/symbolProperty43.js index fcb1fd3f8e511..fdeb52ca89357 100644 --- a/tests/baselines/reference/symbolProperty43.js +++ b/tests/baselines/reference/symbolProperty43.js @@ -5,8 +5,5 @@ class C { } //// [symbolProperty43.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} diff --git a/tests/baselines/reference/symbolProperty44.js b/tests/baselines/reference/symbolProperty44.js index d4824e79318a3..1f4aaf73b3c20 100644 --- a/tests/baselines/reference/symbolProperty44.js +++ b/tests/baselines/reference/symbolProperty44.js @@ -9,15 +9,11 @@ class C { } //// [symbolProperty44.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get [Symbol.hasInstance]() { + return ""; + } +} diff --git a/tests/baselines/reference/symbolProperty45.js b/tests/baselines/reference/symbolProperty45.js index d056aba9f560d..97b1252b8256d 100644 --- a/tests/baselines/reference/symbolProperty45.js +++ b/tests/baselines/reference/symbolProperty45.js @@ -9,22 +9,11 @@ class C { } //// [symbolProperty45.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - Object.defineProperty(C.prototype, Symbol.toPrimitive, { - get: function () { - return ""; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + get [Symbol.toPrimitive]() { + return ""; + } +} diff --git a/tests/baselines/reference/symbolProperty46.js b/tests/baselines/reference/symbolProperty46.js index 255fbac080944..1d4a373f03cd3 100644 --- a/tests/baselines/reference/symbolProperty46.js +++ b/tests/baselines/reference/symbolProperty46.js @@ -12,20 +12,13 @@ class C { (new C)[Symbol.hasInstance] = ""; //// [symbolProperty46.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - // Should take a string - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + // Should take a string + set [Symbol.hasInstance](x) { + } +} (new C)[Symbol.hasInstance] = 0; (new C)[Symbol.hasInstance] = ""; diff --git a/tests/baselines/reference/symbolProperty47.js b/tests/baselines/reference/symbolProperty47.js index 92429c720c19e..7c6886f280b2e 100644 --- a/tests/baselines/reference/symbolProperty47.js +++ b/tests/baselines/reference/symbolProperty47.js @@ -12,20 +12,13 @@ class C { (new C)[Symbol.hasInstance] = ""; //// [symbolProperty47.js] -var C = (function () { - function C() { +class C { + get [Symbol.hasInstance]() { + return ""; } - Object.defineProperty(C.prototype, Symbol.hasInstance, { - get: function () { - return ""; - }, - // Should take a string - set: function (x) { - }, - enumerable: true, - configurable: true - }); - return C; -})(); + // Should take a string + set [Symbol.hasInstance](x) { + } +} (new C)[Symbol.hasInstance] = 0; (new C)[Symbol.hasInstance] = ""; diff --git a/tests/baselines/reference/symbolProperty48.js b/tests/baselines/reference/symbolProperty48.js index b0dc2b46dba47..283c3d0d2c5b0 100644 --- a/tests/baselines/reference/symbolProperty48.js +++ b/tests/baselines/reference/symbolProperty48.js @@ -11,11 +11,8 @@ module M { var M; (function (M) { var Symbol; - var C = (function () { - function C() { + class C { + [Symbol.iterator]() { } - C.prototype[Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty49.js b/tests/baselines/reference/symbolProperty49.js index ea6e6f2c5234a..027b76f76d16b 100644 --- a/tests/baselines/reference/symbolProperty49.js +++ b/tests/baselines/reference/symbolProperty49.js @@ -11,11 +11,8 @@ module M { var M; (function (M) { M.Symbol; - var C = (function () { - function C() { + class C { + [M.Symbol.iterator]() { } - C.prototype[M.Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty50.js b/tests/baselines/reference/symbolProperty50.js index 0a668e9550980..30c911e8fabb7 100644 --- a/tests/baselines/reference/symbolProperty50.js +++ b/tests/baselines/reference/symbolProperty50.js @@ -10,11 +10,8 @@ module M { //// [symbolProperty50.js] var M; (function (M) { - var C = (function () { - function C() { + class C { + [Symbol.iterator]() { } - C.prototype[Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty51.js b/tests/baselines/reference/symbolProperty51.js index b3b9902fcd650..a9a790984247c 100644 --- a/tests/baselines/reference/symbolProperty51.js +++ b/tests/baselines/reference/symbolProperty51.js @@ -10,11 +10,8 @@ module M { //// [symbolProperty51.js] var M; (function (M) { - var C = (function () { - function C() { + class C { + [Symbol.iterator]() { } - C.prototype[Symbol.iterator] = function () { - }; - return C; - })(); + } })(M || (M = {})); diff --git a/tests/baselines/reference/symbolProperty6.js b/tests/baselines/reference/symbolProperty6.js index 114999dc873e9..311baf2c18774 100644 --- a/tests/baselines/reference/symbolProperty6.js +++ b/tests/baselines/reference/symbolProperty6.js @@ -9,18 +9,13 @@ class C { } //// [symbolProperty6.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol.iterator] = 0; } - C.prototype[Symbol.isRegExp] = function () { - }; - Object.defineProperty(C.prototype, Symbol.toStringTag, { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + [Symbol.isRegExp]() { + } + get [Symbol.toStringTag]() { + return 0; + } +} diff --git a/tests/baselines/reference/symbolProperty7.js b/tests/baselines/reference/symbolProperty7.js index 42d19616ce396..b833eecff32fb 100644 --- a/tests/baselines/reference/symbolProperty7.js +++ b/tests/baselines/reference/symbolProperty7.js @@ -9,18 +9,13 @@ class C { } //// [symbolProperty7.js] -var C = (function () { - function C() { +class C { + constructor() { this[Symbol()] = 0; } - C.prototype[Symbol()] = function () { - }; - Object.defineProperty(C.prototype, Symbol(), { - get: function () { - return 0; - }, - enumerable: true, - configurable: true - }); - return C; -})(); + [Symbol()]() { + } + get [Symbol()]() { + return 0; + } +} diff --git a/tests/baselines/reference/symbolProperty9.js b/tests/baselines/reference/symbolProperty9.js index f97a1d44a21df..e6c8f7299a9e8 100644 --- a/tests/baselines/reference/symbolProperty9.js +++ b/tests/baselines/reference/symbolProperty9.js @@ -11,11 +11,8 @@ i = new C; var c: C = i; //// [symbolProperty9.js] -var C = (function () { - function C() { - } - return C; -})(); +class C { +} var i; i = new C; var c = i; diff --git a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js index 22ce6831f0083..95ab43743aecf 100644 --- a/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js +++ b/tests/baselines/reference/templateStringsArrayTypeRedefinedInES6Mode.js @@ -11,11 +11,8 @@ f({}, 10, 10); f `abcdef${ 1234 }${ 5678 }ghijkl`; //// [templateStringsArrayTypeRedefinedInES6Mode.js] -var TemplateStringsArray = (function () { - function TemplateStringsArray() { - } - return TemplateStringsArray; -})(); +class TemplateStringsArray { +} function f(x, y, z) { } f({}, 10, 10); diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts new file mode 100644 index 0000000000000..776d0b4584790 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationOverloadInES6.ts @@ -0,0 +1,11 @@ +// @target: es6 +class C { + constructor(y: any) + constructor(x: number) { + } +} + +class D { + constructor(y: any) + constructor(x: number, z="hello") {} +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts new file mode 100644 index 0000000000000..e6c71b0674071 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithConstructorInES6.ts @@ -0,0 +1,24 @@ +// @target: es6 +class A { + y: number; + constructor(x: number) { + } + foo(a: any); + foo() { } +} + +class B { + y: number; + x: string = "hello"; + _bar: string; + + constructor(x: number, z = "hello", ...args) { + this.y = 10; + } + baz(...args): string; + baz(z: string, v: number): string { + return this._bar; + } +} + + diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts new file mode 100644 index 0000000000000..c27723e3391f3 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts @@ -0,0 +1,11 @@ +// @target: es6 +class B { + constructor(a: T) { } +} +class C extends B { } +class D extends B { + constructor(a: any) + constructor(b: number) { + super(b); + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts new file mode 100644 index 0000000000000..9b79d1b003bf4 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionInES6.ts @@ -0,0 +1,23 @@ +// @target: es6 +class B { + baz(a: string, y = 10) { } +} +class C extends B { + foo() { } + baz(a: string, y:number) { + super.baz(a, y); + } +} +class D extends C { + constructor() { + super(); + } + + foo() { + super.foo(); + } + + baz() { + super.baz("hello", 10); + } +} diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts new file mode 100644 index 0000000000000..70c0b35763e9b --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithGetterSetterInES6.ts @@ -0,0 +1,28 @@ +// @target:es6 +class C { + _name: string; + get name(): string { + return this._name; + } + static get name2(): string { + return "BYE"; + } + static get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + get ["computedname"]() { + return ""; + } + + set ["computedname"](x: any) { + } + set ["computedname"](y: string) { + } + + set foo(a: string) { } + static set bar(b: number) { } + static set ["computedname"](b: string) { } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts new file mode 100644 index 0000000000000..87114db77392e --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithLiteralPropertyNameInES6.ts @@ -0,0 +1,15 @@ +// @target: es6 +class B { + "hello" = 10; + 0b110 = "world"; + 0o23534 = "WORLD"; + 20 = "twenty"; + "foo"() { } + 0b1110() {} + 11() { } + interface() { } + static "hi" = 10000; + static 22 = "twenty-two"; + static 0b101 = "binary"; + static 0o3235 = "octal"; +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts new file mode 100644 index 0000000000000..c5d95bc6cb16f --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithMethodInES6.ts @@ -0,0 +1,23 @@ +// @target:es6 +class D { + _bar: string; + foo() { } + ["computedName"]() { } + ["computedName"](a: string) { } + ["computedName"](a: string): number { return 1; } + bar(): string { + return this._bar; + } + baz(a: any, x: string): string { + return "HELLO"; + } + static ["computedname"]() { } + static ["computedname"](a: string) { } + static ["computedname"](a: string): boolean { return true; } + static staticMethod() { + var x = 1 + 2; + return x + } + static foo(a: string) { } + static bar(a: string): number { return 1; } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts new file mode 100644 index 0000000000000..dd97cfc85f351 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithPropertyAssignmentInES6.ts @@ -0,0 +1,25 @@ +// @target:es6 +class C { + x: string = "Hello world"; +} + +class D { + x: string = "Hello world"; + y: number; + constructor() { + this.y = 10; + } +} + +class E extends D{ + z: boolean = true; +} + +class F extends D{ + z: boolean = true; + j: string; + constructor() { + super(); + this.j = "HI"; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts new file mode 100644 index 0000000000000..7ed36bb22a2a1 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithStaticPropertyAssignmentInES6.ts @@ -0,0 +1,9 @@ +// @target:es6 +class C { + static z: string = "Foo"; +} + +class D { + x = 20000; + static b = true; +} diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts new file mode 100644 index 0000000000000..4356fcce2ab2c --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithThisKeywordInES6.ts @@ -0,0 +1,19 @@ +// @target: es6 +class B { + x = 10; + constructor() { + this.x = 10; + } + static log(a: number) { } + foo() { + B.log(this.x); + } + + get X() { + return this.x; + } + + set bX(y: number) { + this.x = y; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts new file mode 100644 index 0000000000000..945b21010128d --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts @@ -0,0 +1,23 @@ +// @target: es6 +class B { + x: T; + B: T; + + constructor(a: any) + constructor(a: any,b: T) + constructor(a: T) { this.B = a;} + + foo(a: T) + foo(a: any) + foo(b: string) + foo(): T { + return this.x; + } + + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts new file mode 100644 index 0000000000000..078356f6f1595 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts @@ -0,0 +1,15 @@ +// @target: es6 +class B { + x: T; + B: T; + constructor(a: T) { this.B = a;} + foo(): T { + return this.x; + } + get BB(): T { + return this.B; + } + set BBWith(c: T) { + this.B = c; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts b/tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts new file mode 100644 index 0000000000000..b2517d89657a8 --- /dev/null +++ b/tests/cases/conformance/es6/classDeclaration/parseClassDeclarationInStrictModeByDefaultInES6.ts @@ -0,0 +1,9 @@ +// @target: es6 +class C { + interface = 10; + public implements() { } + public foo(arguments: any) { } + private bar(eval:any) { + arguments = "hello"; + } +} \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts index ff94b6c961763..ac9ffd50fd660 100644 --- a/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts @@ -5,7 +5,5 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [super.bar()]() { } } \ No newline at end of file diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts index 4b0d794b1a791..3b2f66fe588fd 100644 --- a/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts @@ -5,8 +5,6 @@ class Base { } } class C extends Base { - // Gets emitted as super, not _super, which is consistent with - // use of super in static properties initializers. [ { [super.bar()]: 1 }[0] ]() { } diff --git a/tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts b/tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts new file mode 100644 index 0000000000000..4cd9047581f4d --- /dev/null +++ b/tests/cases/conformance/es6/computedProperties/computedPropertyNamesWithStaticProperty.ts @@ -0,0 +1,11 @@ +// @target: es6 +class C { + static staticProp = 10; + get [C.staticProp]() { + return "hello"; + } + set [C.staticProp](x: string) { + var y = x; + } + [C.staticProp]() { } +} \ No newline at end of file diff --git a/tests/cases/unittests/incrementalParser.ts b/tests/cases/unittests/incrementalParser.ts index e785f1cdf0083..422675e9e0afb 100644 --- a/tests/cases/unittests/incrementalParser.ts +++ b/tests/cases/unittests/incrementalParser.ts @@ -686,7 +686,6 @@ module m3 { }\ }); it('Surrounding function declarations with block',() => { - debugger; var source = "declare function F1() { } export function F2() { } declare export function F3() { }" var oldText = ScriptSnapshot.fromString(source); @@ -719,6 +718,15 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + it('Moving methods from object literal to class in strict mode', () => { + var source = "\"use strict\"; var v = { public A() { } public B() { } public C() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); }); @@ -728,6 +736,15 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "class".length, "interface"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + it('Moving index signatures from class to interface in strict mode', () => { + var source = "\"use strict\"; class C { public [a: number]: string; public [a: number]: string; public [a: number]: string }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "class".length, "interface"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18); }); @@ -737,6 +754,16 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "interface".length, "class"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + + it('Moving index signatures from interface to class in strict mode', () => { + var source = "\"use strict\"; interface C { public [a: number]: string; public [a: number]: string; public [a: number]: string }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "interface".length, "class"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 18); }); @@ -755,6 +782,16 @@ module m3 { }\ var oldText = ScriptSnapshot.fromString(source); var newTextAndChange = withChange(oldText, 0, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 0); // As specified in ES6 specification, all parts of a ClassDeclaration or a ClassExpression are strict mode code. + }); + + + it('Moving accessors from object literal to class in strict mode', () => { + var source = "\"use strict\"; var v = { public get A() { } public get B() { } public get C() { } }" + + var oldText = ScriptSnapshot.fromString(source); + var newTextAndChange = withChange(oldText, 14, "var v =".length, "class C"); + compareTrees(oldText, newTextAndChange.text, newTextAndChange.textChangeRange, 4); });