Merge branch 'master' into es6ImportExportEmit

Conflicts:
	src/compiler/diagnosticInformationMap.generated.ts
	src/compiler/diagnosticMessages.json
This commit is contained in:
Mohamed Hegazy
2015-03-16 20:47:08 -07:00
247 changed files with 2930 additions and 2275 deletions
+1 -1
View File
@@ -505,7 +505,7 @@ module ts {
bindChildren(node, 0, /*isBlockScopeContainer*/ false);
break;
case SyntaxKind.ExportAssignment:
if ((<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
if ((<ExportAssignment>node).expression && (<ExportAssignment>node).expression.kind === SyntaxKind.Identifier) {
// An export default clause with an identifier exports all meanings of that identifier
declareSymbol(container.symbol.exports, container.symbol, <Declaration>node, SymbolFlags.Alias, SymbolFlags.AliasExcludes);
}
+26 -8
View File
@@ -567,7 +567,7 @@ module ts {
}
function getTargetOfExportAssignment(node: ExportAssignment): Symbol {
return resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
return node.expression && resolveEntityName(<Identifier>node.expression, SymbolFlags.Value | SymbolFlags.Type | SymbolFlags.Namespace);
}
function getTargetOfImportDeclaration(node: Declaration): Symbol {
@@ -623,7 +623,7 @@ module ts {
if (!links.referenced) {
links.referenced = true;
let node = getDeclarationOfAliasSymbol(symbol);
if (node.kind === SyntaxKind.ExportAssignment) {
if (node.kind === SyntaxKind.ExportAssignment && (<ExportAssignment>node).expression) {
// export default <symbol>
checkExpressionCached((<ExportAssignment>node).expression);
}
@@ -2078,7 +2078,16 @@ module ts {
}
// Handle export default expressions
if (declaration.kind === SyntaxKind.ExportAssignment) {
return links.type = checkExpression((<ExportAssignment>declaration).expression);
var exportAssignment = <ExportAssignment>declaration;
if (exportAssignment.expression) {
return links.type = checkExpression(exportAssignment.expression);
}
else if (exportAssignment.type) {
return links.type = getTypeFromTypeNode(exportAssignment.type);
}
else {
return links.type = anyType;
}
}
// Handle variable, parameter or property
links.type = resolvingType;
@@ -10086,12 +10095,21 @@ module ts {
if (!checkGrammarModifiers(node) && (node.flags & NodeFlags.Modifier)) {
grammarErrorOnFirstToken(node, Diagnostics.An_export_assignment_cannot_have_modifiers);
}
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
if (node.expression) {
if (node.expression.kind === SyntaxKind.Identifier) {
markExportAsReferenced(node);
}
else {
checkExpressionCached(node.expression);
}
}
else {
checkExpressionCached(node.expression);
if (node.type) {
checkSourceElement(node.type);
if (!isInAmbientContext(node)) {
grammarErrorOnFirstToken(node.type, Diagnostics.A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration);
}
}
checkExternalModuleExports(container);
if (node.isExportEquals && languageVersion >= ScriptTarget.ES6) {
@@ -10930,7 +10948,7 @@ module ts {
}
function generateNameForExportAssignment(node: ExportAssignment) {
if (node.expression.kind !== SyntaxKind.Identifier) {
if (node.expression && node.expression.kind !== SyntaxKind.Identifier) {
assignGeneratedName(node, makeUniqueName("default"));
}
}
@@ -158,9 +158,10 @@ module ts {
An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive: { code: 1198, category: DiagnosticCategory.Error, key: "An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive." },
Unterminated_Unicode_escape_sequence: { code: 1199, category: DiagnosticCategory.Error, key: "Unterminated Unicode escape sequence." },
Line_terminator_not_permitted_before_arrow: { code: 1200, category: DiagnosticCategory.Error, key: "Line terminator not permitted before arrow." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1201, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1203, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
A_type_annotation_on_an_export_statement_is_only_allowed_in_an_ambient_external_module_declaration: { code: 1201, category: DiagnosticCategory.Error, key: "A type annotation on an export statement is only allowed in an ambient external module declaration." },
Import_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_import_Asterisk_as_ns_from_mod_import_a_from_mod_or_import_d_from_mod_instead: { code: 1202, category: DiagnosticCategory.Error, key: "Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead." },
Export_assignment_cannot_be_used_when_targeting_ECMAScript_6_or_higher_Consider_using_export_default_instead: { code: 1203, category: DiagnosticCategory.Error, key: "Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead." },
Cannot_compile_external_modules_into_amd_or_commonjs_when_targeting_es6_or_higher: { code: 1204, category: DiagnosticCategory.Error, key: "Cannot compile external modules into amd or commonjs when targeting es6 or higher." },
Duplicate_identifier_0: { code: 2300, category: DiagnosticCategory.Error, key: "Duplicate identifier '{0}'." },
Initializer_of_instance_member_variable_0_cannot_reference_identifier_1_declared_in_the_constructor: { code: 2301, category: DiagnosticCategory.Error, key: "Initializer of instance member variable '{0}' cannot reference identifier '{1}' declared in the constructor." },
Static_members_cannot_reference_class_type_parameters: { code: 2302, category: DiagnosticCategory.Error, key: "Static members cannot reference class type parameters." },
+8 -4
View File
@@ -617,24 +617,28 @@
},
"Unterminated Unicode escape sequence.": {
"category": "Error",
"code": 1199
"code": 1199
},
"Line terminator not permitted before arrow.": {
"category": "Error",
"code": 1200
},
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
"A type annotation on an export statement is only allowed in an ambient external module declaration.": {
"category": "Error",
"code": 1201
},
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
"Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from \"mod\"', 'import {a} from \"mod\"' or 'import d from \"mod\"' instead.": {
"category": "Error",
"code": 1202
},
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
"Export assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'export default' instead.": {
"category": "Error",
"code": 1203
},
"Cannot compile external modules into amd or commonjs when targeting es6 or higher.": {
"category": "Error",
"code": 1204
},
"Duplicate identifier '{0}'.": {
"category": "Error",
+207 -97
View File
@@ -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 && (<PropertyAccessExpression>node.expression).expression.kind === SyntaxKind.SuperKeyword;
}
if (superCall) {
if (superCall && languageVersion < ScriptTarget.ES6) {
write(".call(");
emitThis(node.expression);
if (node.arguments.length) {
@@ -4664,7 +4666,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 (!(<MethodDeclaration>member).body) {
@@ -4682,7 +4684,6 @@ module ts {
emitMemberAccessForPropertyName((<MethodDeclaration>member).name);
emitEnd((<MethodDeclaration>member).name);
write(" = ");
// TODO (drosen): Should we performing emitStart twice on emitStart(member)?
emitStart(member);
emitFunctionDeclaration(<MethodDeclaration>member);
emitEnd(member);
@@ -4702,7 +4703,6 @@ module ts {
write(".prototype");
}
write(", ");
// TODO: Shouldn't emitStart on name occur *here*?
emitExpressionForPropertyName((<AccessorDeclaration>member).name);
emitEnd((<AccessorDeclaration>member).name);
write(", {");
@@ -4742,7 +4742,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) && !(<MethodDeclaration>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((<MethodDeclaration>member).name);
emitSignatureAndBody(<MethodDeclaration>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 && !(<ConstructorDeclaration>member).body) {
emitPinnedOrTripleSlashComments(member);
}
// Check if there is any non-static property assignment
if (member.kind === SyntaxKind.PropertyDeclaration && (<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[] = (<Block>ctor.body).statements;
if (superCall) {
statements = statements.slice(1);
}
emitLines(statements);
}
emitTempDeclarations(/*newLine*/ true);
writeLine();
if (ctor) {
emitLeadingCommentsOfPosition((<Block>ctor.body).statements.end);
}
decreaseIndent();
emitToken(SyntaxKind.CloseBraceToken, ctor ? (<Block>ctor.body).statements.end : node.members.end);
scopeEmitEnd();
emitEnd(<Node>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 (");
@@ -4762,8 +4949,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, () => {
@@ -4800,85 +4987,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 && !(<ConstructorDeclaration>member).body) {
emitPinnedOrTripleSlashComments(member);
}
});
let ctor = getFirstConstructorWithBody(node);
if (ctor) {
emitLeadingComments(ctor);
}
emitStart(<Node>ctor || node);
write("function ");
emitDeclarationName(node);
emitSignatureParameters(ctor);
write(" {");
scopeEmitStart(node, "constructor");
increaseIndent();
if (ctor) {
emitDetachedComments((<Block>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[] = (<Block>ctor.body).statements;
if (superCall) statements = statements.slice(1);
emitLines(statements);
}
emitTempDeclarations(/*newLine*/ true);
writeLine();
if (ctor) {
emitLeadingCommentsOfPosition((<Block>ctor.body).statements.end);
}
decreaseIndent();
emitToken(SyntaxKind.CloseBraceToken, ctor ? (<Block>ctor.body).statements.end : node.members.end);
scopeEmitEnd();
emitEnd(<Node>ctor || node);
if (ctor) {
emitTrailingComments(ctor);
}
exitNameScope(popFrame);
tempCount = saveTempCount;
tempVariables = saveTempVariables;
tempParameters = saveTempParameters;
}
}
function emitInterfaceDeclaration(node: InterfaceDeclaration) {
@@ -5532,8 +5640,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();
@@ -5767,7 +5877,7 @@ module ts {
case SyntaxKind.VariableDeclaration:
return emitVariableDeclaration(<VariableDeclaration>node);
case SyntaxKind.ClassDeclaration:
return emitClassDeclaration(<ClassDeclaration>node);
return languageVersion < ScriptTarget.ES6 ? emitClassDeclarationBelowES6(<ClassDeclaration>node) : emitClassDeclarationForES6AndHigher(<ClassDeclaration>node);
case SyntaxKind.InterfaceDeclaration:
return emitInterfaceDeclaration(<InterfaceDeclaration>node);
case SyntaxKind.EnumDeclaration:
+29 -14
View File
@@ -283,7 +283,8 @@ module ts {
visitNode(cbNode, (<ImportOrExportSpecifier>node).name);
case SyntaxKind.ExportAssignment:
return visitNodes(cbNodes, node.modifiers) ||
visitNode(cbNode, (<ExportAssignment>node).expression);
visitNode(cbNode, (<ExportAssignment>node).expression) ||
visitNode(cbNode, (<ExportAssignment>node).type);
case SyntaxKind.TemplateExpression:
return visitNode(cbNode, (<TemplateExpression>node).head) || visitNodes(cbNodes, (<TemplateExpression>node).templateSpans);
case SyntaxKind.TemplateSpan:
@@ -613,7 +614,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 +832,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 +1987,7 @@ module ts {
//
// let v = new List < A, B >()
//
// then we have a problem. "v = new List<A" doesn't intersect the change range, so we
// then we have a problem. "v = new List<A" doesn't intersect the change range, so we
// start reparsing at "B" and we completely fail to handle this properly.
//
// In order to prevent this, we do not allow a variable declarator to be reused if it
@@ -3008,9 +3009,9 @@ module ts {
Debug.assert(token === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
let node = <ArrowFunction>createNode(SyntaxKind.ArrowFunction, identifier.pos);
let parameter = <ParameterDeclaration>createNode(SyntaxKind.Parameter, identifier.pos);
parameter.name = identifier;
parameter.name = identifier;
finishNode(parameter);
node.parameters = <NodeArray<ParameterDeclaration>>[parameter];
@@ -3140,8 +3141,8 @@ module ts {
function parseParenthesizedArrowFunctionExpressionHead(allowAmbiguity: boolean): ArrowFunction {
let node = <ArrowFunction>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 +3207,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 = <ConditionalExpression>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 +4527,13 @@ module ts {
}
function parseClassDeclaration(fullStart: number, modifiers: ModifiersArray): ClassDeclaration {
let node = <ClassDeclaration>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 = <ClassDeclaration>createNode(SyntaxKind.ClassDeclaration, fullStart);
setModifiers(node, modifiers);
parseExpected(SyntaxKind.ClassKeyword);
node.name = node.flags & NodeFlags.Default ? parseOptionalIdentifier() : parseIdentifier();
@@ -4546,7 +4553,10 @@ module ts {
else {
node.members = createMissingList<ClassElement>();
}
return finishNode(node);
var finishedNode = finishNode(node);
setStrictModeContext(savedStrictModeContext);
return finishedNode;
}
function parseHeritageClauses(isClassHeritageClause: boolean): NodeArray<HeritageClause> {
@@ -4774,7 +4784,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((<LiteralExpression>result).text);
}
@@ -4867,12 +4877,17 @@ module ts {
setModifiers(node, modifiers);
if (parseOptional(SyntaxKind.EqualsToken)) {
node.isExportEquals = true;
node.expression = parseAssignmentExpressionOrHigher();
}
else {
parseExpected(SyntaxKind.DefaultKeyword);
if (parseOptional(SyntaxKind.ColonToken)) {
node.type = parseType();
}
else {
node.expression = parseAssignmentExpressionOrHigher();
}
}
//node.exportName = parseIdentifier();
node.expression = parseAssignmentExpressionOrHigher();
parseSemicolon();
return finishNode(node);
}
+2 -1
View File
@@ -944,7 +944,8 @@ module ts {
export interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
export interface FileReference extends TextRange {
+4
View File
@@ -173,6 +173,10 @@ module ts.BreakpointResolver {
return textSpan(node, (<ThrowStatement>node).expression);
case SyntaxKind.ExportAssignment:
if (!(<ExportAssignment>node).expression) {
return undefined;
}
// span on export = id
return textSpan(node, (<ExportAssignment>node).expression);
@@ -765,7 +765,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -2333,9 +2333,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
@@ -796,7 +796,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -2479,9 +2479,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
@@ -797,7 +797,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -2429,9 +2429,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
@@ -834,7 +834,8 @@ declare module "typescript" {
type ExportSpecifier = ImportOrExportSpecifier;
interface ExportAssignment extends Declaration, ModuleElement {
isExportEquals?: boolean;
expression: Expression;
expression?: Expression;
type?: TypeNode;
}
interface FileReference extends TextRange {
fileName: string;
@@ -2602,9 +2602,13 @@ declare module "typescript" {
isExportEquals?: boolean;
>isExportEquals : boolean
expression: Expression;
expression?: Expression;
>expression : Expression
>Expression : Expression
type?: TypeNode;
>type : TypeNode
>TypeNode : TypeNode
}
interface FileReference extends TextRange {
>FileReference : FileReference
+14 -23
View File
@@ -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);
@@ -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;
@@ -20,30 +20,27 @@ class C {
var s;
var n;
var a;
var C = (function () {
function C() {
class C {
[s]() {
}
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;
})();
[n]() {
}
static [s + s]() {
}
[s + n]() {
}
[+s]() {
}
static [""]() {
}
[0]() {
}
[a]() {
}
static [true]() {
}
[`hello bye`]() {
}
static [`hello ${a} bye`]() {
}
}
@@ -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]() {
}
}
@@ -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]() {
}
}
@@ -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;
}
}
@@ -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) {
}
}
@@ -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()]() {
}
}
@@ -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;
})();
}
}
@@ -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]]() {
}
}
@@ -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.
@@ -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);
@@ -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()]() {
}
}
@@ -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);
}
}
@@ -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]
~~~~~
@@ -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;
@@ -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]]() {
}
}
@@ -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() {
class Base {
}
class C extends Base {
[(super(), "prop")]() {
}
return Base;
})();
var C = (function (_super) {
__extends(C, _super);
function C() {
_super.apply(this, arguments);
}
C.prototype[(_super.call(this), "prop")] = function () {
};
return C;
})(Base);
}
@@ -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);
}
@@ -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;
})();
}
}
@@ -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) {
}
}
@@ -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);
}
@@ -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);
}
}
@@ -11,13 +11,10 @@ class C<T> {
function foo() {
return '';
}
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
return 0;
};
C.prototype[foo()] = function () {
};
return C;
})();
}
[foo()]() {
}
}
@@ -13,15 +13,12 @@ class C<T> {
function foo() {
return '';
}
var C = (function () {
function C() {
}
C.prototype.bar = function () {
class C {
bar() {
var obj = {
[foo()]() {
}
};
return 0;
};
return C;
})();
}
}
@@ -13,15 +13,12 @@ class C<T> {
function foo() {
return '';
}
var C = (function () {
function C() {
}
C.bar = function () {
class C {
static bar() {
var obj = {
[foo()]() {
}
};
return 0;
};
return C;
})();
}
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames36_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
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;
})();
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames37_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
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;
})();
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames38_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get [1 << 6]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set [1 << 6](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
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;
})();
}
@@ -11,32 +11,15 @@ class C {
}
//// [computedPropertyNames39_ES6.js]
var Foo = (function () {
function Foo() {
class Foo {
}
class Foo2 {
}
class C {
// Computed properties
get [1 << 6]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set [1 << 6](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
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;
})();
}
@@ -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'.
@@ -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) {
}
}
@@ -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;
})();
}
}
@@ -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;
})();
}
}
@@ -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 {
}
@@ -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() {
class Foo {
}
class Foo2 {
}
class C {
}
class D extends C {
// Computed properties
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
return C;
})();
var D = (function (_super) {
__extends(D, _super);
function D() {
_super.apply(this, arguments);
}
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);
}
@@ -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() {
class Foo {
}
class Foo2 {
}
class C {
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
}
class D extends C {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
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);
}
Object.defineProperty(D.prototype, "set1", {
set: function (p) {
},
enumerable: true,
configurable: true
});
return D;
})(C);
}
@@ -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() {
class Foo {
}
class Foo2 {
}
class C {
get ["get1"]() {
return new Foo;
}
return Foo;
})();
var Foo2 = (function () {
function Foo2() {
}
class D extends C {
set ["set1"](p) {
}
return Foo2;
})();
var C = (function () {
function C() {
}
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);
}
Object.defineProperty(D.prototype, "set1", {
set: function (p) {
},
enumerable: true,
configurable: true
});
return D;
})(C);
}
@@ -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]
@@ -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]
@@ -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;
})();
}
@@ -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
@@ -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"}
{"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"}
@@ -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"])
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) name (C["hello"])
2 >Emitted(4, 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 >
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
>>>//# sourceMappingURL=computedPropertyNamesSourceMap1_ES6.js.map1->
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1->
1->Emitted(6, 1) Source(5, 2) + SourceIndex(0)
---
@@ -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;
@@ -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
}
@@ -1,5 +1,5 @@
error TS1203: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1201: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
tests/cases/compiler/constDeclarations_access_2.ts(2,1): error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
tests/cases/compiler/constDeclarations_access_2.ts(4,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
tests/cases/compiler/constDeclarations_access_2.ts(5,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
tests/cases/compiler/constDeclarations_access_2.ts(6,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
@@ -20,12 +20,12 @@ tests/cases/compiler/constDeclarations_access_2.ts(22,3): error TS2449: The oper
tests/cases/compiler/constDeclarations_access_2.ts(24,1): error TS2450: Left-hand side of assignment expression cannot be a constant.
!!! error TS1203: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
==== tests/cases/compiler/constDeclarations_access_2.ts (19 errors) ====
///<reference path='constDeclarations_access_1.ts'/>
import m = require('constDeclarations_access_1');
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
!!! error TS1201: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
!!! error TS1202: Import assignment cannot be used when targeting ECMAScript 6 or higher. Consider using 'import * as ns from "mod"', 'import {a} from "mod"' or 'import d from "mod"' instead.
// Errors
m.x = 1;
~~~
@@ -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() {
@@ -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() {
@@ -28,38 +28,26 @@ class C2 extends C1<number, string, boolean> {
//// [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 () {
return this.b;
};
C1.prototype.getC = function () {
return this.c;
};
return C1;
})();
var C2 = (function (_super) {
__extends(C2, _super);
function C2() {
_super.apply(this, arguments);
}
C2.prototype.doSomethingWithSuperProperties = function () {
getB() {
return this.b;
}
getC() {
return this.c;
}
}
class C2 extends C1 {
doSomethingWithSuperProperties() {
return `${this.a} ${this.b} ${this.c}`;
};
return C2;
})(C1);
}
}
@@ -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") {
}
}
@@ -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
}
@@ -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;
}
}
@@ -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
}
}
@@ -0,0 +1,24 @@
//// [emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts]
class B<T> {
constructor(a: T) { }
}
class C extends B<string> { }
class D extends B<number> {
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);
}
}
@@ -0,0 +1,29 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithExtensionAndTypeArgumentInES6.ts ===
class B<T> {
>B : B<T>
>T : T
constructor(a: T) { }
>a : T
>T : T
}
class C extends B<string> { }
>C : C
>B : B<T>
class D extends B<number> {
>D : D
>B : B<T>
constructor(a: any)
>a : any
constructor(b: number) {
>b : number
super(b);
>super(b) : void
>super : typeof B
>b : number
}
}
@@ -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);
}
}
@@ -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
}
}
@@ -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) {
}
}
@@ -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
}
@@ -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";
@@ -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";
}
@@ -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;
}
}
@@ -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
}
@@ -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";
}
}
@@ -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
}
}
@@ -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;
@@ -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
}
@@ -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;
}
}
@@ -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
}
}
@@ -0,0 +1,39 @@
//// [emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts]
class B<T> {
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;
}
}
@@ -0,0 +1,75 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentAndOverloadInES6.ts ===
class B<T> {
>B : B<T>
>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<T>
>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<T>
>x : T
}
get BB(): T {
>BB : T
>T : T
return this.B;
>this.B : T
>this : B<T>
>B : T
}
set BBWith(c: T) {
>BBWith : T
>c : T
>T : T
this.B = c;
>this.B = c : T
>this.B : T
>this : B<T>
>B : T
>c : T
}
}
@@ -0,0 +1,31 @@
//// [emitClassDeclarationWithTypeArgumentInES6.ts]
class B<T> {
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;
}
}
@@ -0,0 +1,53 @@
=== tests/cases/conformance/es6/classDeclaration/emitClassDeclarationWithTypeArgumentInES6.ts ===
class B<T> {
>B : B<T>
>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<T>
>B : T
>a : T
foo(): T {
>foo : () => T
>T : T
return this.x;
>this.x : T
>this : B<T>
>x : T
}
get BB(): T {
>BB : T
>T : T
return this.B;
>this.B : T
>this : B<T>
>B : T
}
set BBWith(c: T) {
>BBWith : T
>c : T
>T : T
this.B = c;
>this.B = c : T
>this.B : T
>this : B<T>
>B : T
>c : T
}
}
@@ -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) {
}
}
@@ -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) {
}
}
@@ -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;
@@ -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)
};
+2 -2
View File
@@ -1,7 +1,7 @@
error TS1203: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1203: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6-amd.ts (0 errors) ====
class A
+5 -6
View File
@@ -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]
+1 -1
View File
@@ -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"}
{"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"}
+23 -47
View File
@@ -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
>>>//# sourceMappingURL=es6-amd.js.map1->
2 >^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^->
1->
1->Emitted(8, 1) Source(13, 2) + SourceIndex(0)
---
@@ -1,7 +1,7 @@
error TS1203: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1203: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
!!! error TS1204: Cannot compile external modules into amd or commonjs when targeting es6 or higher.
==== tests/cases/compiler/es6-declaration-amd.ts (0 errors) ====
class A
@@ -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]

Some files were not shown because too many files have changed in this diff Show More