Merge pull request #1950 from Microsoft/thanksLua
ES3/ES5 emit support for computed properties
This commit is contained in:
commit
553f2f0974
|
@ -10827,10 +10827,7 @@ module ts {
|
|||
}
|
||||
|
||||
var computedPropertyName = <ComputedPropertyName>node;
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
return grammarErrorOnNode(node, Diagnostics.Computed_property_names_are_only_available_when_targeting_ECMAScript_6_and_higher);
|
||||
}
|
||||
else if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>computedPropertyName.expression).operator === SyntaxKind.CommaToken) {
|
||||
if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>computedPropertyName.expression).operator === SyntaxKind.CommaToken) {
|
||||
return grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,12 @@ module ts {
|
|||
diagnosticMessage: DiagnosticMessage;
|
||||
typeName?: DeclarationName;
|
||||
}
|
||||
|
||||
interface SynthesizedNode extends Node {
|
||||
leadingCommentRanges?: CommentRange[];
|
||||
trailingCommentRanges?: CommentRange[];
|
||||
}
|
||||
|
||||
type GetSymbolAccessibilityDiagnostic = (symbolAccesibilityResult: SymbolAccessiblityResult) => SymbolAccessibilityDiagnostic;
|
||||
|
||||
interface EmitTextWriterWithSymbolWriter extends EmitTextWriter, SymbolWriter {
|
||||
|
@ -196,7 +202,7 @@ module ts {
|
|||
// }
|
||||
// module m {
|
||||
// /* this is line 1 -- Assume current writer indent 8
|
||||
// * line --3 = 8 - 4 + 5
|
||||
// * line --3 = 8 - 4 + 5
|
||||
// More right indented comment */ --4 = 8 - 4 + 11
|
||||
// class c { }
|
||||
// }
|
||||
|
@ -272,7 +278,7 @@ module ts {
|
|||
});
|
||||
}
|
||||
|
||||
function getAllAccessorDeclarations(node: ClassDeclaration, accessor: AccessorDeclaration) {
|
||||
function getAllAccessorDeclarations(declarations: NodeArray<Declaration>, accessor: AccessorDeclaration) {
|
||||
var firstAccessor: AccessorDeclaration;
|
||||
var getAccessor: AccessorDeclaration;
|
||||
var setAccessor: AccessorDeclaration;
|
||||
|
@ -289,7 +295,7 @@ module ts {
|
|||
}
|
||||
}
|
||||
else {
|
||||
forEach(node.members,(member: Declaration) => {
|
||||
forEach(declarations, (member: Declaration) => {
|
||||
if ((member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor)
|
||||
&& (member.flags & NodeFlags.Static) === (accessor.flags & NodeFlags.Static)) {
|
||||
var memberName = getPropertyNameForPropertyNameNode(member.name);
|
||||
|
@ -363,8 +369,8 @@ module ts {
|
|||
|
||||
var aliasDeclarationEmitInfo: AliasDeclarationEmitInfo[] = [];
|
||||
|
||||
// Contains the reference paths that needs to go in the declaration file.
|
||||
// Collecting this separately because reference paths need to be first thing in the declaration file
|
||||
// Contains the reference paths that needs to go in the declaration file.
|
||||
// Collecting this separately because reference paths need to be first thing in the declaration file
|
||||
// and we could be collecting these paths from multiple files into single one with --out option
|
||||
var referencePathsOutput = "";
|
||||
|
||||
|
@ -471,7 +477,7 @@ module ts {
|
|||
// Eg.
|
||||
// export function bar(a: foo.Foo) { }
|
||||
// import foo = require("foo");
|
||||
// Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing,
|
||||
// Writing of function bar would mark alias declaration foo as visible but we haven't yet visited that declaration so do nothing,
|
||||
// we would write alias foo declaration when we visit it since it would now be marked as visible
|
||||
if (aliasEmitInfo) {
|
||||
createAndSetNewTextWriterWithSymbolWriter();
|
||||
|
@ -613,7 +619,7 @@ module ts {
|
|||
}
|
||||
|
||||
function emitEntityName(entityName: EntityName) {
|
||||
var visibilityResult = resolver.isEntityNameVisible(entityName,
|
||||
var visibilityResult = resolver.isEntityNameVisible(entityName,
|
||||
// Aliases can be written asynchronously so use correct enclosing declaration
|
||||
entityName.parent.kind === SyntaxKind.ImportDeclaration ? entityName.parent : enclosingDeclaration);
|
||||
|
||||
|
@ -697,7 +703,7 @@ module ts {
|
|||
function emitModuleElementDeclarationFlags(node: Node) {
|
||||
// If the node is parented in the current source file we need to emit export declare or just export
|
||||
if (node.parent === currentSourceFile) {
|
||||
// If the node is exported
|
||||
// If the node is exported
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
write("export ");
|
||||
}
|
||||
|
@ -735,7 +741,7 @@ module ts {
|
|||
}
|
||||
|
||||
function writeImportDeclaration(node: ImportDeclaration) {
|
||||
// note usage of writer. methods instead of aliases created, just to make sure we are using
|
||||
// note usage of writer. methods instead of aliases created, just to make sure we are using
|
||||
// correct writer especially to handle asynchronous alias writing
|
||||
emitJsDocComments(node);
|
||||
if (node.flags & NodeFlags.Export) {
|
||||
|
@ -1088,7 +1094,7 @@ module ts {
|
|||
}
|
||||
|
||||
function emitTypeOfVariableDeclarationFromTypeLiteral(node: VariableLikeDeclaration) {
|
||||
// if this is property of type literal,
|
||||
// if this is property of type literal,
|
||||
// or is parameter of method/call/construct/index signature of type literal
|
||||
// emit only if type is specified
|
||||
if (node.type) {
|
||||
|
@ -1121,8 +1127,8 @@ module ts {
|
|||
if (hasDynamicName(node)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var accessors = getAllAccessorDeclarations(<ClassDeclaration>node.parent, node);
|
||||
|
||||
var accessors = getAllAccessorDeclarations((<ClassDeclaration>node.parent).members, node);
|
||||
if (node === accessors.firstAccessor) {
|
||||
emitJsDocComments(accessors.getAccessor);
|
||||
emitJsDocComments(accessors.setAccessor);
|
||||
|
@ -1503,7 +1509,7 @@ module ts {
|
|||
referencePathsOutput += "/// <reference path=\"" + declFileName + "\" />" + newLine;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
export function getDeclarationDiagnostics(host: EmitHost, resolver: EmitResolver, targetSourceFile: SourceFile): Diagnostic[] {
|
||||
var diagnostics: Diagnostic[] = [];
|
||||
var jsFilePath = getOwnEmitOutputFilePath(targetSourceFile, host, ".js");
|
||||
|
@ -1597,7 +1603,7 @@ module ts {
|
|||
var emitEnd = function (node: Node) { };
|
||||
|
||||
/** Emit the text for the given token that comes after startPos
|
||||
* This by default writes the text provided with the given tokenKind
|
||||
* This by default writes the text provided with the given tokenKind
|
||||
* but if optional emitFn callback is provided the text is emitted using the callback instead of default text
|
||||
* @param tokenKind the kind of the token to search and emit
|
||||
* @param startPos the position in the source to start searching for the token
|
||||
|
@ -1683,13 +1689,13 @@ module ts {
|
|||
// 1. Relative Column 0 based
|
||||
sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.emittedColumn - prevEncodedEmittedColumn);
|
||||
|
||||
// 2. Relative sourceIndex
|
||||
// 2. Relative sourceIndex
|
||||
sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceIndex - lastEncodedSourceMapSpan.sourceIndex);
|
||||
|
||||
// 3. Relative sourceLine 0 based
|
||||
sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceLine - lastEncodedSourceMapSpan.sourceLine);
|
||||
|
||||
// 4. Relative sourceColumn 0 based
|
||||
// 4. Relative sourceColumn 0 based
|
||||
sourceMapData.sourceMapMappings += base64VLQFormatEncode(lastRecordedSourceMapSpan.sourceColumn - lastEncodedSourceMapSpan.sourceColumn);
|
||||
|
||||
// 5. Relative namePosition 0 based
|
||||
|
@ -1794,7 +1800,7 @@ module ts {
|
|||
|
||||
function recordNewSourceFileStart(node: SourceFile) {
|
||||
// Add the file to tsFilePaths
|
||||
// If sourceroot option: Use the relative path corresponding to the common directory path
|
||||
// If sourceroot option: Use the relative path corresponding to the common directory path
|
||||
// otherwise source locations relative to map file location
|
||||
var sourcesDirectoryPath = compilerOptions.sourceRoot ? host.getCommonSourceDirectory() : sourceMapDir;
|
||||
|
||||
|
@ -1934,7 +1940,7 @@ module ts {
|
|||
sourceMapDecodedMappings: []
|
||||
};
|
||||
|
||||
// Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the
|
||||
// Normalize source root and make sure it has trailing "/" so that it can be used to combine paths with the
|
||||
// relative paths of the sources list in the sourcemap
|
||||
sourceMapData.sourceMapSourceRoot = ts.normalizeSlashes(sourceMapData.sourceMapSourceRoot);
|
||||
if (sourceMapData.sourceMapSourceRoot.length && sourceMapData.sourceMapSourceRoot.charCodeAt(sourceMapData.sourceMapSourceRoot.length - 1) !== CharacterCodes.slash) {
|
||||
|
@ -2012,13 +2018,20 @@ module ts {
|
|||
return result;
|
||||
}
|
||||
|
||||
function recordTempDeclaration(name: Identifier) {
|
||||
function recordTempDeclaration(name: Identifier): void {
|
||||
if (!tempVariables) {
|
||||
tempVariables = [];
|
||||
}
|
||||
tempVariables.push(name);
|
||||
}
|
||||
|
||||
function createAndRecordTempVariable(location: Node): Identifier {
|
||||
var temp = createTempVariable(location, /*forLoopVariable*/ false);
|
||||
recordTempDeclaration(temp);
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
||||
function emitTempDeclarations(newLine: boolean) {
|
||||
if (tempVariables) {
|
||||
if (newLine) {
|
||||
|
@ -2068,9 +2081,6 @@ module ts {
|
|||
}
|
||||
|
||||
function emitList(nodes: Node[], start: number, count: number, multiLine: boolean, trailingComma: boolean) {
|
||||
if (multiLine) {
|
||||
increaseIndent();
|
||||
}
|
||||
for (var i = 0; i < count; i++) {
|
||||
if (multiLine) {
|
||||
if (i) {
|
||||
|
@ -2089,7 +2099,6 @@ module ts {
|
|||
write(",");
|
||||
}
|
||||
if (multiLine) {
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
|
@ -2100,12 +2109,6 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
function emitMultiLineList(nodes: Node[]) {
|
||||
if (nodes) {
|
||||
emitList(nodes, 0, nodes.length, /*multiline*/ true, /*trailingComma*/ false);
|
||||
}
|
||||
}
|
||||
|
||||
function emitLines(nodes: Node[]) {
|
||||
emitLinesStartingAt(nodes, /*startIndex*/ 0);
|
||||
}
|
||||
|
@ -2250,10 +2253,10 @@ module ts {
|
|||
// All binary expressions have lower precedence than '+' apart from '*', '/', and '%'
|
||||
// which have greater precedence and '-' which has equal precedence.
|
||||
// All unary operators have a higher precedence apart from yield.
|
||||
// Arrow functions and conditionals have a lower precedence,
|
||||
// Arrow functions and conditionals have a lower precedence,
|
||||
// although we convert the former into regular function expressions in ES5 mode,
|
||||
// and in ES6 mode this function won't get called anyway.
|
||||
//
|
||||
//
|
||||
// TODO (drosen): Note that we need to account for the upcoming 'yield' and
|
||||
// spread ('...') unary operators that are anticipated for ES6.
|
||||
switch (expression.kind) {
|
||||
|
@ -2284,7 +2287,10 @@ module ts {
|
|||
|
||||
// This function specifically handles numeric/string literals for enum and accessor 'identifiers'.
|
||||
// In a sense, it does not actually emit identifiers as much as it declares a name for a specific property.
|
||||
// For example, this is utilized when feeding in a result to Object.defineProperty.
|
||||
function emitExpressionForPropertyName(node: DeclarationName) {
|
||||
Debug.assert(node.kind !== SyntaxKind.BindingElement);
|
||||
|
||||
if (node.kind === SyntaxKind.StringLiteral) {
|
||||
emitLiteral(<LiteralExpression>node);
|
||||
}
|
||||
|
@ -2457,7 +2463,13 @@ module ts {
|
|||
i++;
|
||||
}
|
||||
write("[");
|
||||
if (multiLine) {
|
||||
increaseIndent();
|
||||
}
|
||||
emitList(elements, pos, i - pos, multiLine, trailingComma && i === length);
|
||||
if (multiLine) {
|
||||
decreaseIndent();
|
||||
}
|
||||
write("]");
|
||||
pos = i;
|
||||
}
|
||||
|
@ -2475,8 +2487,15 @@ module ts {
|
|||
}
|
||||
else if (languageVersion >= ScriptTarget.ES6) {
|
||||
write("[");
|
||||
emitList(elements, 0, elements.length, /*multiLine*/ (node.flags & NodeFlags.MultiLine) !== 0,
|
||||
var multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
|
||||
if (multiLine) {
|
||||
increaseIndent();
|
||||
}
|
||||
emitList(elements, 0, elements.length, /*multiLine*/ multiLine,
|
||||
/*trailingComma*/ elements.hasTrailingComma);
|
||||
if (multiLine) {
|
||||
decreaseIndent();
|
||||
}
|
||||
write("]");
|
||||
}
|
||||
else {
|
||||
|
@ -2485,23 +2504,264 @@ module ts {
|
|||
}
|
||||
}
|
||||
|
||||
function emitObjectLiteral(node: ObjectLiteralExpression) {
|
||||
function emitObjectLiteralBody(node: ObjectLiteralExpression, numElements: number) {
|
||||
write("{");
|
||||
var properties = node.properties;
|
||||
if (properties.length) {
|
||||
var multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
|
||||
|
||||
var multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
|
||||
|
||||
if (numElements > 0) {
|
||||
var properties = node.properties;
|
||||
if (!multiLine) {
|
||||
write(" ");
|
||||
}
|
||||
emitList(properties, 0, properties.length, /*multiLine*/ multiLine,
|
||||
else {
|
||||
increaseIndent();
|
||||
}
|
||||
emitList(properties, 0, numElements, /*multiLine*/ multiLine,
|
||||
/*trailingComma*/ properties.hasTrailingComma && languageVersion >= ScriptTarget.ES5);
|
||||
if (!multiLine) {
|
||||
write(" ");
|
||||
}
|
||||
else {
|
||||
decreaseIndent();
|
||||
}
|
||||
}
|
||||
|
||||
write("}");
|
||||
}
|
||||
|
||||
function createSynthesizedNode(kind: SyntaxKind): Node {
|
||||
var node = createNode(kind);
|
||||
node.pos = -1;
|
||||
node.end = -1;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void {
|
||||
var parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex);
|
||||
return emit(parenthesizedObjectLiteral);
|
||||
}
|
||||
|
||||
function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral: ObjectLiteralExpression, firstComputedPropertyIndex: number): ParenthesizedExpression {
|
||||
// For computed properties, we need to create a unique handle to the object
|
||||
// literal so we can modify it without risking internal assignments tainting the object.
|
||||
var tempVar = createAndRecordTempVariable(originalObjectLiteral);
|
||||
|
||||
// Hold onto the initial non-computed properties in a new object literal,
|
||||
// then create the rest through property accesses on the temp variable.
|
||||
var initialObjectLiteral = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
|
||||
initialObjectLiteral.properties = <NodeArray<ObjectLiteralElement>>originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex);
|
||||
initialObjectLiteral.flags |= NodeFlags.MultiLine;
|
||||
|
||||
// The comma expressions that will patch the object literal.
|
||||
// This will end up being something like '_a = { ... }, _a.x = 10, _a.y = 20, _a'.
|
||||
var propertyPatches = createBinaryExpression(tempVar, SyntaxKind.EqualsToken, initialObjectLiteral);
|
||||
|
||||
ts.forEach(originalObjectLiteral.properties, property => {
|
||||
var patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property);
|
||||
if (patchedProperty) {
|
||||
// TODO(drosen): Preserve comments
|
||||
//var leadingComments = getLeadingCommentRanges(currentSourceFile.text, property.pos);
|
||||
//var trailingComments = getTrailingCommentRanges(currentSourceFile.text, property.end);
|
||||
//addCommentsToSynthesizedNode(patchedProperty, leadingComments, trailingComments);
|
||||
|
||||
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, patchedProperty);
|
||||
}
|
||||
});
|
||||
|
||||
// Finally, return the temp variable.
|
||||
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, tempVar);
|
||||
|
||||
var result = createParenthesizedExpression(propertyPatches);
|
||||
|
||||
// TODO(drosen): Preserve comments
|
||||
// var leadingComments = getLeadingCommentRanges(currentSourceFile.text, originalObjectLiteral.pos);
|
||||
// var trailingComments = getTrailingCommentRanges(currentSourceFile.text, originalObjectLiteral.end);
|
||||
//addCommentsToSynthesizedNode(result, leadingComments, trailingComments);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function addCommentsToSynthesizedNode(node: SynthesizedNode, leadingCommentRanges: CommentRange[], trailingCommentRanges: CommentRange[]): void {
|
||||
node.leadingCommentRanges = leadingCommentRanges;
|
||||
node.trailingCommentRanges = trailingCommentRanges;
|
||||
}
|
||||
|
||||
// Returns 'undefined' if a property has already been accounted for
|
||||
// (e.g. a 'get' accessor which has already been emitted along with its 'set' accessor).
|
||||
function tryCreatePatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, tempVar: Identifier, property: ObjectLiteralElement): Expression {
|
||||
var leftHandSide = createMemberAccessForPropertyName(tempVar, property.name);
|
||||
var maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property);
|
||||
|
||||
return maybeRightHandSide && createBinaryExpression(leftHandSide, SyntaxKind.EqualsToken, maybeRightHandSide);
|
||||
}
|
||||
|
||||
function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, property: ObjectLiteralElement) {
|
||||
switch (property.kind) {
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return (<PropertyAssignment>property).initializer;
|
||||
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
var prefix = createIdentifier(resolver.getExpressionNamePrefix((<ShorthandPropertyAssignment>property).name));
|
||||
return createPropertyAccessExpression(prefix, (<ShorthandPropertyAssignment>property).name);
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return createFunctionExpression((<MethodDeclaration>property).parameters, (<MethodDeclaration>property).body);
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
var { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(objectLiteral.properties, <AccessorDeclaration>property);
|
||||
|
||||
// Only emit the first accessor.
|
||||
if (firstAccessor !== property) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var propertyDescriptor = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
|
||||
|
||||
var descriptorProperties = <NodeArray<ObjectLiteralElement>>[];
|
||||
if (getAccessor) {
|
||||
var getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body));
|
||||
descriptorProperties.push(getProperty);
|
||||
}
|
||||
if (setAccessor) {
|
||||
var setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body));
|
||||
descriptorProperties.push(setProperty);
|
||||
}
|
||||
|
||||
var trueExpr = <PrimaryExpression>createSynthesizedNode(SyntaxKind.TrueKeyword);
|
||||
|
||||
var enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr);
|
||||
descriptorProperties.push(enumerableTrue);
|
||||
|
||||
var configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr);
|
||||
descriptorProperties.push(configurableTrue);
|
||||
|
||||
propertyDescriptor.properties = descriptorProperties;
|
||||
|
||||
var objectDotDefineProperty = createPropertyAccessExpression(createIdentifier("Object"), createIdentifier("defineProperty"));
|
||||
return createCallExpression(objectDotDefineProperty, createNodeArray(propertyDescriptor));
|
||||
|
||||
default:
|
||||
Debug.fail(`ObjectLiteralElement kind ${property.kind} not accounted for.`);
|
||||
}
|
||||
}
|
||||
|
||||
function createParenthesizedExpression(expression: Expression) {
|
||||
var result = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
|
||||
result.expression = expression;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createNodeArray<T extends Node>(...elements: T[]): NodeArray<T> {
|
||||
var result = <NodeArray<T>>elements;
|
||||
result.pos = -1;
|
||||
result.end = -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression): BinaryExpression {
|
||||
var result = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression);
|
||||
result.operator = operator;
|
||||
result.left = left;
|
||||
result.right = right;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createMemberAccessForPropertyName(expression: LeftHandSideExpression, memberName: DeclarationName): PropertyAccessExpression | ElementAccessExpression {
|
||||
if (memberName.kind === SyntaxKind.Identifier) {
|
||||
return createPropertyAccessExpression(expression, <Identifier>memberName);
|
||||
}
|
||||
else if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) {
|
||||
return createElementAccessExpression(expression, <LiteralExpression>memberName);
|
||||
}
|
||||
else if (memberName.kind === SyntaxKind.ComputedPropertyName) {
|
||||
return createElementAccessExpression(expression, (<ComputedPropertyName>memberName).expression);
|
||||
}
|
||||
else {
|
||||
Debug.fail(`Kind '${memberName.kind}' not accounted for.`);
|
||||
}
|
||||
}
|
||||
|
||||
function createPropertyAssignment(name: LiteralExpression | Identifier, initializer: Expression) {
|
||||
var result = <PropertyAssignment>createSynthesizedNode(SyntaxKind.PropertyAssignment);
|
||||
result.name = name;
|
||||
result.initializer = initializer;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createFunctionExpression(parameters: NodeArray<ParameterDeclaration>, body: Block): FunctionExpression {
|
||||
var result = <FunctionExpression>createSynthesizedNode(SyntaxKind.FunctionExpression);
|
||||
result.parameters = parameters;
|
||||
result.body = body;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
|
||||
var result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
|
||||
result.expression = expression;
|
||||
result.name = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
|
||||
var result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
|
||||
result.expression = expression;
|
||||
result.argumentExpression = argumentExpression;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createIdentifier(name: string) {
|
||||
var result = <Identifier>createSynthesizedNode(SyntaxKind.Identifier);
|
||||
result.text = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createCallExpression(invokedExpression: MemberExpression, arguments: NodeArray<Expression>) {
|
||||
var result = <CallExpression>createSynthesizedNode(SyntaxKind.CallExpression);
|
||||
result.expression = invokedExpression;
|
||||
result.arguments = arguments;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function emitObjectLiteral(node: ObjectLiteralExpression): void {
|
||||
var properties = node.properties;
|
||||
|
||||
if (languageVersion < ScriptTarget.ES6) {
|
||||
var numProperties = properties.length;
|
||||
|
||||
// Find the first computed property.
|
||||
// Everything until that point can be emitted as part of the initial object literal.
|
||||
var numInitialNonComputedProperties = numProperties;
|
||||
for (var i = 0, n = properties.length; i < n; i++) {
|
||||
if (properties[i].name.kind === SyntaxKind.ComputedPropertyName) {
|
||||
numInitialNonComputedProperties = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var hasComputedProperty = numInitialNonComputedProperties !== properties.length;
|
||||
if (hasComputedProperty) {
|
||||
emitDownlevelObjectLiteralWithComputedProperties(node, numInitialNonComputedProperties);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Ordinary case: either the object has no computed properties
|
||||
// or we're compiling with an ES6+ target.
|
||||
emitObjectLiteralBody(node, properties.length);
|
||||
}
|
||||
|
||||
function emitComputedPropertyName(node: ComputedPropertyName) {
|
||||
write("[");
|
||||
emit(node.expression);
|
||||
|
@ -2532,7 +2792,7 @@ module ts {
|
|||
// export var obj = { y };
|
||||
// }
|
||||
// The short-hand property in obj need to emit as such ... = { y : m.y } regardless of the TargetScript version
|
||||
if (languageVersion < ScriptTarget.ES6 || resolver.getExpressionNamePrefix(node.name)) {
|
||||
if (languageVersion <= ScriptTarget.ES5 || resolver.getExpressionNamePrefix(node.name)) {
|
||||
// Emit identifier as an identifier
|
||||
write(": ");
|
||||
// Even though this is stored as identifier treat it as an expression
|
||||
|
@ -2595,8 +2855,8 @@ module ts {
|
|||
emit(node);
|
||||
return node;
|
||||
}
|
||||
var temp = createTempVariable(node);
|
||||
recordTempDeclaration(temp);
|
||||
var temp = createAndRecordTempVariable(node);
|
||||
|
||||
write("(");
|
||||
emit(temp);
|
||||
write(" = ");
|
||||
|
@ -2699,7 +2959,7 @@ module ts {
|
|||
var operand = (<TypeAssertion>node.expression).expression;
|
||||
|
||||
// Make sure we consider all nested cast expressions, e.g.:
|
||||
// (<any><number><any>-A).x;
|
||||
// (<any><number><any>-A).x;
|
||||
while (operand.kind == SyntaxKind.TypeAssertionExpression) {
|
||||
operand = (<TypeAssertion>operand).expression;
|
||||
}
|
||||
|
@ -2707,7 +2967,7 @@ module ts {
|
|||
// We have an expression of the form: (<Type>SubExpr)
|
||||
// Emitting this as (SubExpr) is really not desirable. We would like to emit the subexpr as is.
|
||||
// Omitting the parentheses, however, could cause change in the semantics of the generated
|
||||
// code if the casted expression has a lower precedence than the rest of the expression, e.g.:
|
||||
// code if the casted expression has a lower precedence than the rest of the expression, e.g.:
|
||||
// (<any>new A).foo should be emitted as (new A).foo and not new A.foo
|
||||
// (<any>typeof A).toString() should be emitted as (typeof A).toString() and not typeof A.toString()
|
||||
// new (<any>A()) should be emitted as new (A()) and not new A()
|
||||
|
@ -3617,6 +3877,7 @@ module ts {
|
|||
}
|
||||
|
||||
function emitMemberAccessForPropertyName(memberName: DeclarationName) {
|
||||
// TODO: (jfreeman,drosen): comment on why this is emitNode instead of emit here.
|
||||
if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) {
|
||||
write("[");
|
||||
emitNode(memberName);
|
||||
|
@ -3666,13 +3927,14 @@ module ts {
|
|||
emitLeadingComments(member);
|
||||
emitStart(member);
|
||||
emitStart((<MethodDeclaration>member).name);
|
||||
emitNode(node.name);
|
||||
emitNode(node.name); // TODO (shkamat,drosen): comment for why emitNode instead of emit.
|
||||
if (!(member.flags & NodeFlags.Static)) {
|
||||
write(".prototype");
|
||||
}
|
||||
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);
|
||||
|
@ -3681,7 +3943,7 @@ module ts {
|
|||
emitTrailingComments(member);
|
||||
}
|
||||
else if (member.kind === SyntaxKind.GetAccessor || member.kind === SyntaxKind.SetAccessor) {
|
||||
var accessors = getAllAccessorDeclarations(node, <AccessorDeclaration>member);
|
||||
var accessors = getAllAccessorDeclarations(node.members, <AccessorDeclaration>member);
|
||||
if (member === accessors.firstAccessor) {
|
||||
writeLine();
|
||||
emitStart(member);
|
||||
|
@ -3692,6 +3954,7 @@ module ts {
|
|||
write(".prototype");
|
||||
}
|
||||
write(", ");
|
||||
// TODO: Shouldn't emitStart on name occur *here*?
|
||||
emitExpressionForPropertyName((<AccessorDeclaration>member).name);
|
||||
emitEnd((<AccessorDeclaration>member).name);
|
||||
write(", {");
|
||||
|
@ -4247,12 +4510,12 @@ module ts {
|
|||
return false;
|
||||
|
||||
case SyntaxKind.ModuleDeclaration:
|
||||
// Only emit the leading/trailing comments for a module if we're actually
|
||||
// Only emit the leading/trailing comments for a module if we're actually
|
||||
// emitting the module as well.
|
||||
return shouldEmitModuleDeclaration(<ModuleDeclaration>node);
|
||||
|
||||
case SyntaxKind.EnumDeclaration:
|
||||
// Only emit the leading/trailing comments for an enum if we're actually
|
||||
// Only emit the leading/trailing comments for an enum if we're actually
|
||||
// emitting the module as well.
|
||||
return shouldEmitEnumDeclaration(<EnumDeclaration>node);
|
||||
}
|
||||
|
@ -4476,7 +4739,7 @@ module ts {
|
|||
}
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, { pos: pos, end: pos }, leadingComments);
|
||||
// Leading comments are emitted at /*leading comment1 */space/*leading comment*/space
|
||||
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
emitComments(currentSourceFile, writer, leadingComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
}
|
||||
|
||||
function emitDetachedCommentsAtPosition(node: TextRange) {
|
||||
|
@ -4492,7 +4755,7 @@ module ts {
|
|||
|
||||
if (commentLine >= lastCommentLine + 2) {
|
||||
// There was a blank line between the last comment and this comment. This
|
||||
// comment is not part of the copyright comments. Return what we have so
|
||||
// comment is not part of the copyright comments. Return what we have so
|
||||
// far.
|
||||
return detachedComments;
|
||||
}
|
||||
|
@ -4531,7 +4794,7 @@ module ts {
|
|||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
return currentSourceFile.text.charCodeAt(comment.pos + 2) === CharacterCodes.exclamation;
|
||||
}
|
||||
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
|
||||
// Verify this is /// comment, but do the regexp match only when we first can find /// in the comment text
|
||||
// so that we don't end up computing comment string and doing match for all // comments
|
||||
else if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.slash &&
|
||||
comment.pos + 2 < comment.end &&
|
||||
|
@ -4549,7 +4812,7 @@ module ts {
|
|||
|
||||
function writeDeclarationFile(jsFilePath: string, sourceFile: SourceFile) {
|
||||
var emitDeclarationResult = emitDeclarations(host, resolver, diagnostics, jsFilePath, sourceFile);
|
||||
// TODO(shkamat): Should we not write any declaration file if any of them can produce error,
|
||||
// TODO(shkamat): Should we not write any declaration file if any of them can produce error,
|
||||
// or should we just not write this file like we are doing now
|
||||
if (!emitDeclarationResult.reportedDeclarationError) {
|
||||
var declarationOutput = emitDeclarationResult.referencePathsOutput;
|
||||
|
@ -4566,7 +4829,7 @@ module ts {
|
|||
writeFile(host, diagnostics, removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||
emitJavaScript(jsFilePath, sourceFile);
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
tests/cases/conformance/Symbols/ES5SymbolProperty1.ts(7,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty1.ts(7,6): error TS2471: A computed property name of the form 'Symbol.foo' must be of type 'symbol'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty1.ts (2 errors) ====
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty1.ts (1 errors) ====
|
||||
interface SymbolConstructor {
|
||||
foo: string;
|
||||
}
|
||||
|
@ -10,8 +9,6 @@ tests/cases/conformance/Symbols/ES5SymbolProperty1.ts(7,6): error TS2471: A comp
|
|||
|
||||
var obj = {
|
||||
[Symbol.foo]: 0
|
||||
~~~~~~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~
|
||||
!!! error TS2471: A computed property name of the form 'Symbol.foo' must be of type 'symbol'.
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ obj[Symbol.foo];
|
|||
|
||||
//// [ES5SymbolProperty1.js]
|
||||
var Symbol;
|
||||
var obj = {
|
||||
[Symbol.foo]: 0
|
||||
};
|
||||
var obj = (_a = {}, _a[Symbol.foo] = 0, _a);
|
||||
obj[Symbol.foo];
|
||||
var _a;
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(5,9): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(5,10): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty2.ts(10,11): error TS2304: Cannot find name 'Symbol'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts (3 errors) ====
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty2.ts (2 errors) ====
|
||||
module M {
|
||||
var Symbol;
|
||||
|
||||
export class C {
|
||||
[Symbol.iterator]() { }
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
tests/cases/conformance/Symbols/ES5SymbolProperty3.ts(4,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty3.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts (2 errors) ====
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty3.ts (1 errors) ====
|
||||
var Symbol;
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
tests/cases/conformance/Symbols/ES5SymbolProperty4.ts(4,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty4.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty4.ts (2 errors) ====
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty4.ts (1 errors) ====
|
||||
var Symbol: { iterator: string };
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
tests/cases/conformance/Symbols/ES5SymbolProperty5.ts(4,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty5.ts(7,1): error TS2346: Supplied parameters do not match any signature of call target.
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty5.ts (2 errors) ====
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty5.ts (1 errors) ====
|
||||
var Symbol: { iterator: symbol };
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
}
|
||||
|
||||
(new C)[Symbol.iterator](0) // Should error
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(2,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(2,6): error TS2304: Cannot find name 'Symbol'.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty6.ts(5,9): error TS2304: Cannot find name 'Symbol'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty6.ts (2 errors) ====
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~
|
||||
!!! error TS2304: Cannot find name 'Symbol'.
|
||||
}
|
||||
|
|
|
@ -1,14 +1,11 @@
|
|||
tests/cases/conformance/Symbols/ES5SymbolProperty7.ts(4,5): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/Symbols/ES5SymbolProperty7.ts(4,6): error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty7.ts (2 errors) ====
|
||||
==== tests/cases/conformance/Symbols/ES5SymbolProperty7.ts (1 errors) ====
|
||||
var Symbol: { iterator: any };
|
||||
|
||||
class C {
|
||||
[Symbol.iterator]() { }
|
||||
~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2471: A computed property name of the form 'Symbol.iterator' must be of type 'symbol'.
|
||||
}
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,11): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,12): error TS2304: Cannot find name 'yield'.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts(1,20): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration8_es6.ts (2 errors) ====
|
||||
var v = { [yield]: foo }
|
||||
~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~
|
||||
!!! error TS2304: Cannot find name 'yield'.
|
||||
~~~
|
||||
|
|
|
@ -2,4 +2,5 @@
|
|||
var v = { [yield]: foo }
|
||||
|
||||
//// [FunctionDeclaration8_es6.js]
|
||||
var v = { [yield]: foo };
|
||||
var v = (_a = {}, _a[yield] = foo, _a);
|
||||
var _a;
|
||||
|
|
|
@ -1,15 +1,12 @@
|
|||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(1,10): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,13): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts(2,14): error TS9000: 'yield' expressions are not currently supported.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/functionDeclarations/FunctionDeclaration9_es6.ts (2 errors) ====
|
||||
function * foo() {
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
var v = { [yield]: foo }
|
||||
~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~~~
|
||||
!!! error TS9000: 'yield' expressions are not currently supported.
|
||||
}
|
|
@ -5,5 +5,6 @@ function * foo() {
|
|||
|
||||
//// [FunctionDeclaration9_es6.js]
|
||||
function foo() {
|
||||
var v = { []: foo };
|
||||
var v = (_a = {}, _a[] = foo, _a);
|
||||
var _a;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,10 @@
|
|||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,11): error TS9001: Generators are not currently supported.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,12): error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts(1,13): error TS2304: Cannot find name 'foo'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (3 errors) ====
|
||||
==== tests/cases/conformance/es6/functionPropertyAssignments/FunctionPropertyAssignments5_es6.ts (2 errors) ====
|
||||
var v = { *[foo()]() { } }
|
||||
~
|
||||
!!! error TS9001: Generators are not currently supported.
|
||||
~~~~~~~
|
||||
!!! error TS1167: Computed property names are only available when targeting ECMAScript 6 and higher.
|
||||
~~~
|
||||
!!! error TS2304: Cannot find name 'foo'.
|
|
@ -2,4 +2,5 @@
|
|||
var v = { *[foo()]() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments5_es6.js]
|
||||
var v = { [foo()]: function () { } };
|
||||
var v = (_a = {}, _a[foo()] = function () { }, _a);
|
||||
var _a;
|
||||
|
|
24
tests/baselines/reference/computedPropertyNames10_ES5.js
Normal file
24
tests/baselines/reference/computedPropertyNames10_ES5.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
//// [computedPropertyNames10_ES5.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
var v = {
|
||||
[s]() { },
|
||||
[n]() { },
|
||||
[s + s]() { },
|
||||
[s + n]() { },
|
||||
[+s]() { },
|
||||
[""]() { },
|
||||
[0]() { },
|
||||
[a]() { },
|
||||
[<any>true]() { },
|
||||
[`hello bye`]() { },
|
||||
[`hello ${a} bye`]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames10_ES5.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var v = (_a = {}, _a[s] = function () { }, _a[n] = function () { }, _a[s + s] = function () { }, _a[s + n] = function () { }, _a[+s] = function () { }, _a[""] = function () { }, _a[0] = function () { }, _a[a] = function () { }, _a[true] = function () { }, _a["hello bye"] = function () { }, _a["hello " + a + " bye"] = function () { }, _a);
|
||||
var _a;
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames10.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames10_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames10.ts]
|
||||
//// [computedPropertyNames10_ES6.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
|
@ -16,7 +16,7 @@ var v = {
|
|||
[`hello ${a} bye`]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames10.js]
|
||||
//// [computedPropertyNames10_ES6.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
46
tests/baselines/reference/computedPropertyNames10_ES6.types
Normal file
46
tests/baselines/reference/computedPropertyNames10_ES6.types
Normal file
|
@ -0,0 +1,46 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames10_ES6.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ [s]() { }, [n]() { }, [s + s]() { }, [s + n]() { }, [+s]() { }, [""]() { }, [0]() { }, [a]() { }, [<any>true]() { }, [`hello bye`]() { }, [`hello ${a} bye`]() { }} : {}
|
||||
|
||||
[s]() { },
|
||||
>s : string
|
||||
|
||||
[n]() { },
|
||||
>n : number
|
||||
|
||||
[s + s]() { },
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
[s + n]() { },
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
|
||||
[+s]() { },
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
[""]() { },
|
||||
[0]() { },
|
||||
[a]() { },
|
||||
>a : any
|
||||
|
||||
[<any>true]() { },
|
||||
><any>true : any
|
||||
|
||||
[`hello bye`]() { },
|
||||
[`hello ${a} bye`]() { }
|
||||
>a : any
|
||||
}
|
36
tests/baselines/reference/computedPropertyNames11_ES5.js
Normal file
36
tests/baselines/reference/computedPropertyNames11_ES5.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
//// [computedPropertyNames11_ES5.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
var v = {
|
||||
get [s]() { return 0; },
|
||||
set [n](v) { },
|
||||
get [s + s]() { return 0; },
|
||||
set [s + n](v) { },
|
||||
get [+s]() { return 0; },
|
||||
set [""](v) { },
|
||||
get [0]() { return 0; },
|
||||
set [a](v) { },
|
||||
get [<any>true]() { return 0; },
|
||||
set [`hello bye`](v) { },
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames11_ES5.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var v = (_a = {}, _a[s] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a[n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[s + s] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a[s + n] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[+s] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a[""] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[0] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a[a] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a[true] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a["hello bye"] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a["hello " + a + " bye"] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a);
|
||||
var _a;
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames11.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames11_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames11.ts]
|
||||
//// [computedPropertyNames11_ES6.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
|
@ -16,7 +16,7 @@ var v = {
|
|||
get [`hello ${a} bye`]() { return 0; }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames11.js]
|
||||
//// [computedPropertyNames11_ES6.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
53
tests/baselines/reference/computedPropertyNames11_ES6.types
Normal file
53
tests/baselines/reference/computedPropertyNames11_ES6.types
Normal file
|
@ -0,0 +1,53 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames11_ES6.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [s]() { return 0; }, set [n](v) { }, get [s + s]() { return 0; }, set [s + n](v) { }, get [+s]() { return 0; }, set [""](v) { }, get [0]() { return 0; }, set [a](v) { }, get [<any>true]() { return 0; }, set [`hello bye`](v) { }, get [`hello ${a} bye`]() { return 0; }} : {}
|
||||
|
||||
get [s]() { return 0; },
|
||||
>s : string
|
||||
|
||||
set [n](v) { },
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
get [s + s]() { return 0; },
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
set [s + n](v) { },
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
get [+s]() { return 0; },
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
set [""](v) { },
|
||||
>v : any
|
||||
|
||||
get [0]() { return 0; },
|
||||
set [a](v) { },
|
||||
>a : any
|
||||
>v : any
|
||||
|
||||
get [<any>true]() { return 0; },
|
||||
><any>true : any
|
||||
|
||||
set [`hello bye`](v) { },
|
||||
>v : any
|
||||
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
>a : any
|
||||
}
|
|
@ -1,17 +1,17 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(10,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(11,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(10,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(11,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12.ts (11 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES5.ts (11 errors) ====
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
31
tests/baselines/reference/computedPropertyNames12_ES5.js
Normal file
31
tests/baselines/reference/computedPropertyNames12_ES5.js
Normal file
|
@ -0,0 +1,31 @@
|
|||
//// [computedPropertyNames12_ES5.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
class C {
|
||||
[s]: number;
|
||||
[n] = n;
|
||||
static [s + s]: string;
|
||||
[s + n] = 2;
|
||||
[+s]: typeof s;
|
||||
static [""]: number;
|
||||
[0]: number;
|
||||
[a]: number;
|
||||
static [<any>true]: number;
|
||||
[`hello bye`] = 0;
|
||||
static [`hello ${a} bye`] = 0
|
||||
}
|
||||
|
||||
//// [computedPropertyNames12_ES5.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
this[n] = n;
|
||||
this[s + n] = 2;
|
||||
this["hello bye"] = 0;
|
||||
}
|
||||
C["hello " + a + " bye"] = 0;
|
||||
return C;
|
||||
})();
|
|
@ -0,0 +1,52 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(5,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(6,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(7,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(8,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(9,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(10,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(11,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(12,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(13,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(14,5): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts(15,12): error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames12_ES6.ts (11 errors) ====
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
class C {
|
||||
[s]: number;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[n] = n;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
static [s + s]: string;
|
||||
~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[s + n] = 2;
|
||||
~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[+s]: typeof s;
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
static [""]: number;
|
||||
~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[0]: number;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[a]: number;
|
||||
~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
static [<any>true]: number;
|
||||
~~~~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
[`hello bye`] = 0;
|
||||
~~~~~~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
static [`hello ${a} bye`] = 0
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS1166: A computed property name in a class property declaration must directly refer to a built-in symbol.
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames12.ts]
|
||||
//// [computedPropertyNames12_ES6.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
|
@ -16,7 +16,7 @@ class C {
|
|||
static [`hello ${a} bye`] = 0
|
||||
}
|
||||
|
||||
//// [computedPropertyNames12.js]
|
||||
//// [computedPropertyNames12_ES6.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
38
tests/baselines/reference/computedPropertyNames13_ES5.js
Normal file
38
tests/baselines/reference/computedPropertyNames13_ES5.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
//// [computedPropertyNames13_ES5.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
class C {
|
||||
[s]() {}
|
||||
[n]() { }
|
||||
static [s + s]() { }
|
||||
[s + n]() { }
|
||||
[+s]() { }
|
||||
static [""]() { }
|
||||
[0]() { }
|
||||
[a]() { }
|
||||
static [<any>true]() { }
|
||||
[`hello bye`]() { }
|
||||
static [`hello ${a} bye`]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames13_ES5.js]
|
||||
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;
|
||||
})();
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames13.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames13_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames13.ts]
|
||||
//// [computedPropertyNames13_ES6.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
|
@ -16,7 +16,7 @@ class C {
|
|||
static [`hello ${a} bye`]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames13.js]
|
||||
//// [computedPropertyNames13_ES6.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
45
tests/baselines/reference/computedPropertyNames13_ES6.types
Normal file
45
tests/baselines/reference/computedPropertyNames13_ES6.types
Normal file
|
@ -0,0 +1,45 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames13_ES6.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
[s]() {}
|
||||
>s : string
|
||||
|
||||
[n]() { }
|
||||
>n : number
|
||||
|
||||
static [s + s]() { }
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
[s + n]() { }
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
|
||||
[+s]() { }
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
static [""]() { }
|
||||
[0]() { }
|
||||
[a]() { }
|
||||
>a : any
|
||||
|
||||
static [<any>true]() { }
|
||||
><any>true : any
|
||||
|
||||
[`hello bye`]() { }
|
||||
static [`hello ${a} bye`]() { }
|
||||
>a : any
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(6,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts(8,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts(6,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts(8,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames14.ts (6 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES5.ts (6 errors) ====
|
||||
var b: boolean;
|
||||
class C {
|
||||
[b]() {}
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames14.ts]
|
||||
//// [computedPropertyNames14_ES5.ts]
|
||||
var b: boolean;
|
||||
class C {
|
||||
[b]() {}
|
||||
|
@ -9,7 +9,7 @@ class C {
|
|||
static [null]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames14.js]
|
||||
//// [computedPropertyNames14_ES5.js]
|
||||
var b;
|
||||
var C = (function () {
|
||||
function C() {
|
|
@ -0,0 +1,30 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts(3,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts(4,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts(5,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts(6,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts(8,12): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames14_ES6.ts (6 errors) ====
|
||||
var b: boolean;
|
||||
class C {
|
||||
[b]() {}
|
||||
~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
static [true]() { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
[[]]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
static [{}]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
[undefined]() { }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
static [null]() { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
}
|
24
tests/baselines/reference/computedPropertyNames14_ES6.js
Normal file
24
tests/baselines/reference/computedPropertyNames14_ES6.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
//// [computedPropertyNames14_ES6.ts]
|
||||
var b: boolean;
|
||||
class C {
|
||||
[b]() {}
|
||||
static [true]() { }
|
||||
[[]]() { }
|
||||
static [{}]() { }
|
||||
[undefined]() { }
|
||||
static [null]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames14_ES6.js]
|
||||
var b;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[b] = function () { };
|
||||
C[true] = function () { };
|
||||
C.prototype[[]] = function () { };
|
||||
C[{}] = function () { };
|
||||
C.prototype[undefined] = function () { };
|
||||
C[null] = function () { };
|
||||
return C;
|
||||
})();
|
|
@ -1,8 +1,8 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES5.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES5.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames15.ts (2 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES5.ts (2 errors) ====
|
||||
var p1: number | string;
|
||||
var p2: number | number[];
|
||||
var p3: string | boolean;
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames15.ts]
|
||||
//// [computedPropertyNames15_ES5.ts]
|
||||
var p1: number | string;
|
||||
var p2: number | number[];
|
||||
var p3: string | boolean;
|
||||
|
@ -8,7 +8,7 @@ class C {
|
|||
[p3]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames15.js]
|
||||
//// [computedPropertyNames15_ES5.js]
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
|
@ -0,0 +1,17 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES6.ts(6,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES6.ts(7,5): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames15_ES6.ts (2 errors) ====
|
||||
var p1: number | string;
|
||||
var p2: number | number[];
|
||||
var p3: string | boolean;
|
||||
class C {
|
||||
[p1]() { }
|
||||
[p2]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
[p3]() { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
}
|
22
tests/baselines/reference/computedPropertyNames15_ES6.js
Normal file
22
tests/baselines/reference/computedPropertyNames15_ES6.js
Normal file
|
@ -0,0 +1,22 @@
|
|||
//// [computedPropertyNames15_ES6.ts]
|
||||
var p1: number | string;
|
||||
var p2: number | number[];
|
||||
var p3: string | boolean;
|
||||
class C {
|
||||
[p1]() { }
|
||||
[p2]() { }
|
||||
[p3]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames15_ES6.js]
|
||||
var p1;
|
||||
var p2;
|
||||
var p3;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype[p1] = function () { };
|
||||
C.prototype[p2] = function () { };
|
||||
C.prototype[p3] = function () { };
|
||||
return C;
|
||||
})();
|
94
tests/baselines/reference/computedPropertyNames16_ES5.js
Normal file
94
tests/baselines/reference/computedPropertyNames16_ES5.js
Normal file
|
@ -0,0 +1,94 @@
|
|||
//// [computedPropertyNames16_ES5.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
class C {
|
||||
get [s]() { return 0;}
|
||||
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 [<any>true]() { return 0; }
|
||||
set [`hello bye`](v) { }
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames16_ES5.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
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;
|
||||
})();
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames16.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames16_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames16.ts]
|
||||
//// [computedPropertyNames16_ES6.ts]
|
||||
var s: string;
|
||||
var n: number;
|
||||
var a: any;
|
||||
|
@ -16,7 +16,7 @@ class C {
|
|||
get [`hello ${a} bye`]() { return 0; }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames16.js]
|
||||
//// [computedPropertyNames16_ES6.js]
|
||||
var s;
|
||||
var n;
|
||||
var a;
|
52
tests/baselines/reference/computedPropertyNames16_ES6.types
Normal file
52
tests/baselines/reference/computedPropertyNames16_ES6.types
Normal file
|
@ -0,0 +1,52 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames16_ES6.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
var n: number;
|
||||
>n : number
|
||||
|
||||
var a: any;
|
||||
>a : any
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
get [s]() { return 0;}
|
||||
>s : string
|
||||
|
||||
set [n](v) { }
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
static get [s + s]() { return 0; }
|
||||
>s + s : string
|
||||
>s : string
|
||||
>s : string
|
||||
|
||||
set [s + n](v) { }
|
||||
>s + n : string
|
||||
>s : string
|
||||
>n : number
|
||||
>v : any
|
||||
|
||||
get [+s]() { return 0; }
|
||||
>+s : number
|
||||
>s : string
|
||||
|
||||
static set [""](v) { }
|
||||
>v : any
|
||||
|
||||
get [0]() { return 0; }
|
||||
set [a](v) { }
|
||||
>a : any
|
||||
>v : any
|
||||
|
||||
static get [<any>true]() { return 0; }
|
||||
><any>true : any
|
||||
|
||||
set [`hello bye`](v) { }
|
||||
>v : any
|
||||
|
||||
get [`hello ${a} bye`]() { return 0; }
|
||||
>a : any
|
||||
}
|
|
@ -1,12 +1,12 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(3,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(4,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts(8,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES5.ts(3,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES5.ts(4,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES5.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES5.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES5.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES5.ts(8,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames17.ts (6 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES5.ts (6 errors) ====
|
||||
var b: boolean;
|
||||
class C {
|
||||
get [b]() { return 0;}
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames17.ts]
|
||||
//// [computedPropertyNames17_ES5.ts]
|
||||
var b: boolean;
|
||||
class C {
|
||||
get [b]() { return 0;}
|
||||
|
@ -9,7 +9,7 @@ class C {
|
|||
set [null](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames17.js]
|
||||
//// [computedPropertyNames17_ES5.js]
|
||||
var b;
|
||||
var C = (function () {
|
||||
function C() {
|
|
@ -0,0 +1,30 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES6.ts(3,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES6.ts(4,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES6.ts(5,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES6.ts(6,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES6.ts(7,16): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES6.ts(8,9): error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames17_ES6.ts (6 errors) ====
|
||||
var b: boolean;
|
||||
class C {
|
||||
get [b]() { return 0;}
|
||||
~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
static set [true](v) { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
get [[]]() { return 0; }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
set [{}](v) { }
|
||||
~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
static get [undefined]() { return 0; }
|
||||
~~~~~~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
set [null](v) { }
|
||||
~~~~~~
|
||||
!!! error TS2464: A computed property name must be of type 'string', 'number', 'symbol', or 'any'.
|
||||
}
|
54
tests/baselines/reference/computedPropertyNames17_ES6.js
Normal file
54
tests/baselines/reference/computedPropertyNames17_ES6.js
Normal file
|
@ -0,0 +1,54 @@
|
|||
//// [computedPropertyNames17_ES6.ts]
|
||||
var b: boolean;
|
||||
class C {
|
||||
get [b]() { return 0;}
|
||||
static set [true](v) { }
|
||||
get [[]]() { return 0; }
|
||||
set [{}](v) { }
|
||||
static get [undefined]() { return 0; }
|
||||
set [null](v) { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames17_ES6.js]
|
||||
var b;
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
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;
|
||||
})();
|
12
tests/baselines/reference/computedPropertyNames18_ES5.js
Normal file
12
tests/baselines/reference/computedPropertyNames18_ES5.js
Normal file
|
@ -0,0 +1,12 @@
|
|||
//// [computedPropertyNames18_ES5.ts]
|
||||
function foo() {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames18_ES5.js]
|
||||
function foo() {
|
||||
var obj = (_a = {}, _a[this.bar] = 0, _a);
|
||||
var _a;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames18.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames18_ES5.ts ===
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
//// [computedPropertyNames18.ts]
|
||||
//// [computedPropertyNames18_ES6.ts]
|
||||
function foo() {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames18.js]
|
||||
//// [computedPropertyNames18_ES6.js]
|
||||
function foo() {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
14
tests/baselines/reference/computedPropertyNames18_ES6.types
Normal file
14
tests/baselines/reference/computedPropertyNames18_ES6.types
Normal file
|
@ -0,0 +1,14 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames18_ES6.ts ===
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar]: 0 } : {}
|
||||
|
||||
[this.bar]: 0
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames19.ts(3,10): error TS2331: 'this' cannot be referenced in a module body.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames19_ES5.ts(3,10): error TS2331: 'this' cannot be referenced in a module body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames19.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames19_ES5.ts (1 errors) ====
|
||||
module M {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
13
tests/baselines/reference/computedPropertyNames19_ES5.js
Normal file
13
tests/baselines/reference/computedPropertyNames19_ES5.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
//// [computedPropertyNames19_ES5.ts]
|
||||
module M {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames19_ES5.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
var obj = (_a = {}, _a[this.bar] = 0, _a);
|
||||
var _a;
|
||||
})(M || (M = {}));
|
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames19_ES6.ts(3,10): error TS2331: 'this' cannot be referenced in a module body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames19_ES6.ts (1 errors) ====
|
||||
module M {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
~~~~
|
||||
!!! error TS2331: 'this' cannot be referenced in a module body.
|
||||
}
|
||||
}
|
|
@ -1,11 +1,11 @@
|
|||
//// [computedPropertyNames19.ts]
|
||||
//// [computedPropertyNames19_ES6.ts]
|
||||
module M {
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames19.js]
|
||||
//// [computedPropertyNames19_ES6.js]
|
||||
var M;
|
||||
(function (M) {
|
||||
var obj = {
|
11
tests/baselines/reference/computedPropertyNames1_ES5.js
Normal file
11
tests/baselines/reference/computedPropertyNames1_ES5.js
Normal file
|
@ -0,0 +1,11 @@
|
|||
//// [computedPropertyNames1_ES5.ts]
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
set [0 + 1](v: string) { } //No error
|
||||
}
|
||||
|
||||
//// [computedPropertyNames1_ES5.js]
|
||||
var v = (_a = {}, _a[0 + 1] = Object.defineProperty({ get: function () {
|
||||
return 0;
|
||||
}, enumerable: true, configurable: true }), _a[0 + 1] = Object.defineProperty({ set: function (v) { }, enumerable: true, configurable: true }), _a);
|
||||
var _a;
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames1.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames1_ES5.ts ===
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {}
|
|
@ -1,10 +1,10 @@
|
|||
//// [computedPropertyNames1.ts]
|
||||
//// [computedPropertyNames1_ES6.ts]
|
||||
var v = {
|
||||
get [0 + 1]() { return 0 },
|
||||
set [0 + 1](v: string) { } //No error
|
||||
}
|
||||
|
||||
//// [computedPropertyNames1.js]
|
||||
//// [computedPropertyNames1_ES6.js]
|
||||
var v = {
|
||||
get [0 + 1]() {
|
||||
return 0;
|
12
tests/baselines/reference/computedPropertyNames1_ES6.types
Normal file
12
tests/baselines/reference/computedPropertyNames1_ES6.types
Normal file
|
@ -0,0 +1,12 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames1_ES6.ts ===
|
||||
var v = {
|
||||
>v : {}
|
||||
>{ get [0 + 1]() { return 0 }, set [0 + 1](v: string) { } //No error} : {}
|
||||
|
||||
get [0 + 1]() { return 0 },
|
||||
>0 + 1 : number
|
||||
|
||||
set [0 + 1](v: string) { } //No error
|
||||
>0 + 1 : number
|
||||
>v : string
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
//// [computedPropertyNames20.ts]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
|
||||
//// [computedPropertyNames20.js]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
};
|
8
tests/baselines/reference/computedPropertyNames20_ES5.js
Normal file
8
tests/baselines/reference/computedPropertyNames20_ES5.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
//// [computedPropertyNames20_ES5.ts]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
|
||||
//// [computedPropertyNames20_ES5.js]
|
||||
var obj = (_a = {}, _a[this.bar] = 0, _a);
|
||||
var _a;
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames20.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames20_ES5.ts ===
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar]: 0} : {}
|
9
tests/baselines/reference/computedPropertyNames20_ES6.js
Normal file
9
tests/baselines/reference/computedPropertyNames20_ES6.js
Normal file
|
@ -0,0 +1,9 @@
|
|||
//// [computedPropertyNames20_ES6.ts]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
|
||||
//// [computedPropertyNames20_ES6.js]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
};
|
10
tests/baselines/reference/computedPropertyNames20_ES6.types
Normal file
10
tests/baselines/reference/computedPropertyNames20_ES6.types
Normal file
|
@ -0,0 +1,10 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames20_ES6.ts ===
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar]: 0} : {}
|
||||
|
||||
[this.bar]: 0
|
||||
>this.bar : any
|
||||
>this : any
|
||||
>bar : any
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames21.ts(5,6): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames21_ES5.ts(5,6): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames21.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames21_ES5.ts (1 errors) ====
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames21.ts]
|
||||
//// [computedPropertyNames21_ES5.ts]
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
|
@ -6,7 +6,7 @@ class C {
|
|||
[this.bar()]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames21.js]
|
||||
//// [computedPropertyNames21_ES5.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames21_ES6.ts(5,6): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames21_ES6.ts (1 errors) ====
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[this.bar()]() { }
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
}
|
18
tests/baselines/reference/computedPropertyNames21_ES6.js
Normal file
18
tests/baselines/reference/computedPropertyNames21_ES6.js
Normal file
|
@ -0,0 +1,18 @@
|
|||
//// [computedPropertyNames21_ES6.ts]
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[this.bar()]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames21_ES6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
C.prototype[this.bar()] = function () { };
|
||||
return C;
|
||||
})();
|
21
tests/baselines/reference/computedPropertyNames22_ES5.js
Normal file
21
tests/baselines/reference/computedPropertyNames22_ES5.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//// [computedPropertyNames22_ES5.ts]
|
||||
class C {
|
||||
bar() {
|
||||
var obj = {
|
||||
[this.bar()]() { }
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames22_ES5.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var obj = (_a = {}, _a[this.bar()] = function () { }, _a);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
return C;
|
||||
})();
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames22.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames22_ES5.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames22.ts]
|
||||
//// [computedPropertyNames22_ES6.ts]
|
||||
class C {
|
||||
bar() {
|
||||
var obj = {
|
||||
|
@ -8,7 +8,7 @@ class C {
|
|||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames22.js]
|
||||
//// [computedPropertyNames22_ES6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
21
tests/baselines/reference/computedPropertyNames22_ES6.types
Normal file
21
tests/baselines/reference/computedPropertyNames22_ES6.types
Normal file
|
@ -0,0 +1,21 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames22_ES6.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
bar() {
|
||||
>bar : () => number
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [this.bar()]() { } } : {}
|
||||
|
||||
[this.bar()]() { }
|
||||
>this.bar() : number
|
||||
>this.bar : () => number
|
||||
>this : C
|
||||
>bar : () => number
|
||||
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames23.ts(6,12): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames23_ES5.ts(6,12): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames23.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames23_ES5.ts (1 errors) ====
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
21
tests/baselines/reference/computedPropertyNames23_ES5.js
Normal file
21
tests/baselines/reference/computedPropertyNames23_ES5.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
//// [computedPropertyNames23_ES5.ts]
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[
|
||||
{ [this.bar()]: 1 }[0]
|
||||
]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames23_ES5.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
C.prototype[(_a = {}, _a[this.bar()] = 1, _a)[0]] = function () { };
|
||||
return C;
|
||||
})();
|
||||
var _a;
|
|
@ -0,0 +1,14 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames23_ES6.ts(6,12): error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames23_ES6.ts (1 errors) ====
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
[
|
||||
{ [this.bar()]: 1 }[0]
|
||||
~~~~
|
||||
!!! error TS2465: 'this' cannot be referenced in a computed property name.
|
||||
]() { }
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames23.ts]
|
||||
//// [computedPropertyNames23_ES6.ts]
|
||||
class C {
|
||||
bar() {
|
||||
return 0;
|
||||
|
@ -8,7 +8,7 @@ class C {
|
|||
]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames23.js]
|
||||
//// [computedPropertyNames23_ES6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames24.ts(9,6): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
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.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES5.ts (1 errors) ====
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames24.ts]
|
||||
//// [computedPropertyNames24_ES5.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
|
@ -10,7 +10,7 @@ class C extends Base {
|
|||
[super.bar()]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames24.js]
|
||||
//// [computedPropertyNames24_ES5.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; }
|
|
@ -0,0 +1,16 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES6.ts(9,6): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames24_ES6.ts (1 errors) ====
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
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.
|
||||
}
|
37
tests/baselines/reference/computedPropertyNames24_ES6.js
Normal file
37
tests/baselines/reference/computedPropertyNames24_ES6.js
Normal file
|
@ -0,0 +1,37 @@
|
|||
//// [computedPropertyNames24_ES6.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
// Gets emitted as super, not _super, which is consistent with
|
||||
// use of super in static properties initializers.
|
||||
[super.bar()]() { }
|
||||
}
|
||||
|
||||
//// [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 () {
|
||||
return 0;
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _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 () { };
|
||||
return C;
|
||||
})(Base);
|
42
tests/baselines/reference/computedPropertyNames25_ES5.js
Normal file
42
tests/baselines/reference/computedPropertyNames25_ES5.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
//// [computedPropertyNames25_ES5.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
foo() {
|
||||
var obj = {
|
||||
[super.bar()]() { }
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames25_ES5.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 () {
|
||||
return 0;
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C.prototype.foo = function () {
|
||||
var obj = (_a = {}, _a[_super.prototype.bar.call(this)] = function () { }, _a);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
return C;
|
||||
})(Base);
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames25.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames25_ES5.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames25.ts]
|
||||
//// [computedPropertyNames25_ES6.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
|
@ -13,7 +13,7 @@ class C extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames25.js]
|
||||
//// [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; }
|
31
tests/baselines/reference/computedPropertyNames25_ES6.types
Normal file
31
tests/baselines/reference/computedPropertyNames25_ES6.types
Normal file
|
@ -0,0 +1,31 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames25_ES6.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
|
||||
bar() {
|
||||
>bar : () => number
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class C extends Base {
|
||||
>C : C
|
||||
>Base : Base
|
||||
|
||||
foo() {
|
||||
>foo : () => number
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [super.bar()]() { } } : {}
|
||||
|
||||
[super.bar()]() { }
|
||||
>super.bar() : number
|
||||
>super.bar : () => number
|
||||
>super : Base
|
||||
>bar : () => number
|
||||
|
||||
};
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames26.ts(10,12): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
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.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES5.ts (1 errors) ====
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
40
tests/baselines/reference/computedPropertyNames26_ES5.js
Normal file
40
tests/baselines/reference/computedPropertyNames26_ES5.js
Normal file
|
@ -0,0 +1,40 @@
|
|||
//// [computedPropertyNames26_ES5.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
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]
|
||||
]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames26_ES5.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 () {
|
||||
return 0;
|
||||
};
|
||||
return Base;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _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)[0]] = function () { };
|
||||
return C;
|
||||
})(Base);
|
||||
var _a;
|
|
@ -0,0 +1,18 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES6.ts(10,12): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames26_ES6.ts (1 errors) ====
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
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]
|
||||
~~~~~
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
]() { }
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames26.ts]
|
||||
//// [computedPropertyNames26_ES6.ts]
|
||||
class Base {
|
||||
bar() {
|
||||
return 0;
|
||||
|
@ -12,7 +12,7 @@ class C extends Base {
|
|||
]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames26.js]
|
||||
//// [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; }
|
|
@ -1,7 +1,7 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27.ts(4,7): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES5.ts(4,7): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames27.ts (1 errors) ====
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES5.ts (1 errors) ====
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
|
@ -1,11 +1,11 @@
|
|||
//// [computedPropertyNames27.ts]
|
||||
//// [computedPropertyNames27_ES5.ts]
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
[(super(), "prop")]() { }
|
||||
}
|
||||
|
||||
//// [computedPropertyNames27.js]
|
||||
//// [computedPropertyNames27_ES5.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; }
|
|
@ -0,0 +1,11 @@
|
|||
tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES6.ts(4,7): error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/computedProperties/computedPropertyNames27_ES6.ts (1 errors) ====
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
[(super(), "prop")]() { }
|
||||
~~~~~
|
||||
!!! error TS2466: 'super' cannot be referenced in a computed property name.
|
||||
}
|
27
tests/baselines/reference/computedPropertyNames27_ES6.js
Normal file
27
tests/baselines/reference/computedPropertyNames27_ES6.js
Normal file
|
@ -0,0 +1,27 @@
|
|||
//// [computedPropertyNames27_ES6.ts]
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
[(super(), "prop")]() { }
|
||||
}
|
||||
|
||||
//// [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);
|
||||
}
|
||||
C.prototype[(_super.call(this), "prop")] = function () { };
|
||||
return C;
|
||||
})(Base);
|
33
tests/baselines/reference/computedPropertyNames28_ES5.js
Normal file
33
tests/baselines/reference/computedPropertyNames28_ES5.js
Normal file
|
@ -0,0 +1,33 @@
|
|||
//// [computedPropertyNames28_ES5.ts]
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
constructor() {
|
||||
super();
|
||||
var obj = {
|
||||
[(super(), "prop")]() { }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames28_ES5.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);
|
||||
var obj = (_a = {}, _a[(_super.call(this), "prop")] = function () { }, _a);
|
||||
var _a;
|
||||
}
|
||||
return C;
|
||||
})(Base);
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames28.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames28_ES5.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames28.ts]
|
||||
//// [computedPropertyNames28_ES6.ts]
|
||||
class Base {
|
||||
}
|
||||
class C extends Base {
|
||||
|
@ -10,7 +10,7 @@ class C extends Base {
|
|||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames28.js]
|
||||
//// [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; }
|
26
tests/baselines/reference/computedPropertyNames28_ES6.types
Normal file
26
tests/baselines/reference/computedPropertyNames28_ES6.types
Normal file
|
@ -0,0 +1,26 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames28_ES6.ts ===
|
||||
class Base {
|
||||
>Base : Base
|
||||
}
|
||||
class C extends Base {
|
||||
>C : C
|
||||
>Base : Base
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
>super() : void
|
||||
>super : typeof Base
|
||||
|
||||
var obj = {
|
||||
>obj : {}
|
||||
>{ [(super(), "prop")]() { } } : {}
|
||||
|
||||
[(super(), "prop")]() { }
|
||||
>(super(), "prop") : string
|
||||
>super(), "prop" : string
|
||||
>super() : void
|
||||
>super : typeof Base
|
||||
|
||||
};
|
||||
}
|
||||
}
|
26
tests/baselines/reference/computedPropertyNames29_ES5.js
Normal file
26
tests/baselines/reference/computedPropertyNames29_ES5.js
Normal file
|
@ -0,0 +1,26 @@
|
|||
//// [computedPropertyNames29_ES5.ts]
|
||||
class C {
|
||||
bar() {
|
||||
() => {
|
||||
var obj = {
|
||||
[this.bar()]() { } // needs capture
|
||||
};
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames29_ES5.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.bar = function () {
|
||||
var _this = this;
|
||||
(function () {
|
||||
var obj = (_a = {}, _a[_this.bar()] = function () { }, _a);
|
||||
var _a;
|
||||
});
|
||||
return 0;
|
||||
};
|
||||
return C;
|
||||
})();
|
|
@ -1,4 +1,4 @@
|
|||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames29.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames29_ES5.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
//// [computedPropertyNames29.ts]
|
||||
//// [computedPropertyNames29_ES6.ts]
|
||||
class C {
|
||||
bar() {
|
||||
() => {
|
||||
|
@ -10,7 +10,7 @@ class C {
|
|||
}
|
||||
}
|
||||
|
||||
//// [computedPropertyNames29.js]
|
||||
//// [computedPropertyNames29_ES6.js]
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue