mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into binaryExpressionEmit
Conflicts: src/compiler/checker.ts
This commit is contained in:
@@ -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).operatorToken.kind === SyntaxKind.CommaToken) {
|
||||
if (computedPropertyName.expression.kind === SyntaxKind.BinaryExpression && (<BinaryExpression>computedPropertyName.expression).operatorToken.kind === SyntaxKind.CommaToken) {
|
||||
return grammarErrorOnNode(computedPropertyName.expression, Diagnostics.A_comma_expression_is_not_allowed_in_a_computed_property_name);
|
||||
}
|
||||
}
|
||||
|
||||
+327
-58
@@ -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 {
|
||||
@@ -170,16 +176,17 @@ module ts {
|
||||
function writeCommentRange(currentSourceFile: SourceFile, writer: EmitTextWriter, comment: CommentRange, newLine: string){
|
||||
if (currentSourceFile.text.charCodeAt(comment.pos + 1) === CharacterCodes.asterisk) {
|
||||
var firstCommentLineAndCharacter = getLineAndCharacterOfPosition(currentSourceFile, comment.pos);
|
||||
var lastLine = getLineStarts(currentSourceFile).length;
|
||||
var lineCount = getLineStarts(currentSourceFile).length;
|
||||
var firstCommentLineIndent: number;
|
||||
for (var pos = comment.pos, currentLine = firstCommentLineAndCharacter.line; pos < comment.end; currentLine++) {
|
||||
var nextLineStart = currentLine === lastLine ? (comment.end + 1) : getPositionFromLineAndCharacter(currentSourceFile, currentLine + 1, /*character*/1);
|
||||
var nextLineStart = (currentLine + 1) === lineCount
|
||||
? currentSourceFile.text.length + 1
|
||||
: getStartPositionOfLine(currentLine + 1, currentSourceFile);
|
||||
|
||||
if (pos !== comment.pos) {
|
||||
// If we are not emitting first line, we need to write the spaces to adjust the alignment
|
||||
if (firstCommentLineIndent === undefined) {
|
||||
firstCommentLineIndent = calculateIndent(getPositionFromLineAndCharacter(currentSourceFile, firstCommentLineAndCharacter.line, /*character*/1),
|
||||
comment.pos);
|
||||
firstCommentLineIndent = calculateIndent(getStartPositionOfLine(firstCommentLineAndCharacter.line, currentSourceFile), comment.pos);
|
||||
}
|
||||
|
||||
// These are number of spaces writer is going to write at current indent
|
||||
@@ -195,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 { }
|
||||
// }
|
||||
@@ -271,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;
|
||||
@@ -288,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);
|
||||
@@ -362,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 = "";
|
||||
|
||||
@@ -470,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();
|
||||
@@ -612,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);
|
||||
|
||||
@@ -696,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 ");
|
||||
}
|
||||
@@ -734,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) {
|
||||
@@ -1087,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) {
|
||||
@@ -1120,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);
|
||||
@@ -1502,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");
|
||||
@@ -1596,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
|
||||
@@ -1682,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
|
||||
@@ -1738,6 +1745,11 @@ module ts {
|
||||
|
||||
function recordSourceMapSpan(pos: number) {
|
||||
var sourceLinePos = getLineAndCharacterOfPosition(currentSourceFile, pos);
|
||||
|
||||
// Convert the location to be one-based.
|
||||
sourceLinePos.line++;
|
||||
sourceLinePos.character++;
|
||||
|
||||
var emittedLine = writer.getLine();
|
||||
var emittedColumn = writer.getColumn();
|
||||
|
||||
@@ -1788,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;
|
||||
|
||||
@@ -1928,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) {
|
||||
@@ -2006,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) {
|
||||
@@ -2062,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) {
|
||||
@@ -2083,7 +2099,6 @@ module ts {
|
||||
write(",");
|
||||
}
|
||||
if (multiLine) {
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
}
|
||||
}
|
||||
@@ -2094,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);
|
||||
}
|
||||
@@ -2244,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) {
|
||||
@@ -2278,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);
|
||||
}
|
||||
@@ -2451,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;
|
||||
}
|
||||
@@ -2469,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 {
|
||||
@@ -2479,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.operatorToken = createSynthesizedNode(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);
|
||||
@@ -2526,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
|
||||
@@ -2589,8 +2855,8 @@ module ts {
|
||||
emit(node);
|
||||
return node;
|
||||
}
|
||||
var temp = createTempVariable(node);
|
||||
recordTempDeclaration(temp);
|
||||
var temp = createAndRecordTempVariable(node);
|
||||
|
||||
write("(");
|
||||
emit(temp);
|
||||
write(" = ");
|
||||
@@ -2693,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;
|
||||
}
|
||||
@@ -2701,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()
|
||||
@@ -2984,7 +3250,7 @@ module ts {
|
||||
|
||||
function isOnSameLine(node1: Node, node2: Node) {
|
||||
return getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node1.pos)) ===
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node2.pos));
|
||||
}
|
||||
|
||||
function nodeEndIsOnSameLineAsNodeStart(node1: Node, node2: Node) {
|
||||
@@ -3611,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);
|
||||
@@ -3660,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);
|
||||
@@ -3675,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);
|
||||
@@ -3686,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(", {");
|
||||
@@ -4241,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);
|
||||
}
|
||||
@@ -4470,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) {
|
||||
@@ -4486,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;
|
||||
}
|
||||
@@ -4501,8 +4770,8 @@ module ts {
|
||||
// sure there is at least one blank line between it and the node. If not, it's not
|
||||
// a copyright header.
|
||||
var lastCommentLine = getLineOfLocalPosition(currentSourceFile, detachedComments[detachedComments.length - 1].end);
|
||||
var astLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
|
||||
if (astLine >= lastCommentLine + 2) {
|
||||
var nodeLine = getLineOfLocalPosition(currentSourceFile, skipTrivia(currentSourceFile.text, node.pos));
|
||||
if (nodeLine >= lastCommentLine + 2) {
|
||||
// Valid detachedComments
|
||||
emitNewLineBeforeLeadingComments(currentSourceFile, writer, node, leadingComments);
|
||||
emitComments(currentSourceFile, writer, detachedComments, /*trailingSeparator*/ true, newLine, writeComment);
|
||||
@@ -4525,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 &&
|
||||
@@ -4543,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;
|
||||
@@ -4560,7 +4829,7 @@ module ts {
|
||||
writeFile(host, diagnostics, removeFileExtension(jsFilePath) + ".d.ts", declarationOutput, compilerOptions.emitBOM);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function emitFile(jsFilePath: string, sourceFile?: SourceFile) {
|
||||
emitJavaScript(jsFilePath, sourceFile);
|
||||
|
||||
|
||||
@@ -280,13 +280,13 @@ module ts {
|
||||
return result;
|
||||
}
|
||||
|
||||
export function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
|
||||
return computePositionFromLineAndCharacter(getLineStarts(sourceFile), line, character);
|
||||
export function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number {
|
||||
return computePositionOfLineAndCharacter(getLineStarts(sourceFile), line, character);
|
||||
}
|
||||
|
||||
export function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line > 0 && line <= lineStarts.length);
|
||||
return lineStarts[line - 1] + character - 1;
|
||||
export function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number {
|
||||
Debug.assert(line >= 0 && line < lineStarts.length);
|
||||
return lineStarts[line] + character;
|
||||
}
|
||||
|
||||
export function getLineStarts(sourceFile: SourceFile): number[] {
|
||||
@@ -300,11 +300,11 @@ module ts {
|
||||
// the binary search returns the negative value of the next line start
|
||||
// e.g. if the line starts at [5, 10, 23, 80] and the position requested was 20
|
||||
// then the search will return -2
|
||||
lineNumber = (~lineNumber) - 1;
|
||||
lineNumber = ~lineNumber - 1;
|
||||
}
|
||||
return {
|
||||
line: lineNumber + 1,
|
||||
character: position - lineStarts[lineNumber] + 1
|
||||
line: lineNumber,
|
||||
character: position - lineStarts[lineNumber]
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -72,7 +72,7 @@ module ts {
|
||||
function countLines(program: Program): number {
|
||||
var count = 0;
|
||||
forEach(program.getSourceFiles(), file => {
|
||||
count += getLineAndCharacterOfPosition(file, file.end).line;
|
||||
count += getLineStarts(file).length;
|
||||
});
|
||||
return count;
|
||||
}
|
||||
@@ -88,11 +88,11 @@ module ts {
|
||||
if (diagnostic.file) {
|
||||
var loc = getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start);
|
||||
|
||||
output += diagnostic.file.fileName + "(" + loc.line + "," + loc.character + "): ";
|
||||
output += `${ diagnostic.file.fileName }(${ loc.line + 1 },${ loc.character + 1 }): `;
|
||||
}
|
||||
|
||||
var category = DiagnosticCategory[diagnostic.category].toLowerCase();
|
||||
output += category + " TS" + diagnostic.code + ": " + flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) + sys.newLine;
|
||||
output += `${ category } TS${ diagnostic.code }: ${ flattenDiagnosticMessageText(diagnostic.messageText, sys.newLine) }${ sys.newLine }`;
|
||||
|
||||
sys.write(output);
|
||||
}
|
||||
|
||||
@@ -105,11 +105,16 @@ module ts {
|
||||
return <SourceFile>node;
|
||||
}
|
||||
|
||||
export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number {
|
||||
Debug.assert(line >= 0);
|
||||
return getLineStarts(sourceFile)[line];
|
||||
}
|
||||
|
||||
// This is a useful function for debugging purposes.
|
||||
export function nodePosToString(node: Node): string {
|
||||
var file = getSourceFileOfNode(node);
|
||||
var loc = getLineAndCharacterOfPosition(file, node.pos);
|
||||
return file.fileName + "(" + loc.line + "," + loc.character + ")";
|
||||
return `${ file.fileName }(${ loc.line + 1 },${ loc.character + 1 })`;
|
||||
}
|
||||
|
||||
export function getStartPosOfNode(node: Node): number {
|
||||
|
||||
+19
-27
@@ -398,7 +398,7 @@ module FourSlash {
|
||||
|
||||
var lineStarts = ts.computeLineStarts(this.getFileContent(this.activeFile.fileName));
|
||||
var lineCharPos = ts.computeLineAndCharacterOfPosition(lineStarts, pos);
|
||||
this.scenarioActions.push('<MoveCaretToLineAndChar LineNumber="' + lineCharPos.line + '" CharNumber="' + lineCharPos.character + '" />');
|
||||
this.scenarioActions.push(`<MoveCaretToLineAndChar LineNumber=${ lineCharPos.line + 1 } CharNumber=${ lineCharPos.character + 1 } />`);
|
||||
}
|
||||
|
||||
public moveCaretRight(count = 1) {
|
||||
@@ -2015,39 +2015,31 @@ module FourSlash {
|
||||
|
||||
// Get the text of the entire line the caret is currently at
|
||||
private getCurrentLineContent() {
|
||||
// The current caret position (in line/col terms)
|
||||
var line = this.getCurrentCaretFilePosition().line;
|
||||
// The line/col of the start of this line
|
||||
var pos = this.languageServiceAdapterHost.lineColToPosition(this.activeFile.fileName, line, 1);
|
||||
// The index of the current file
|
||||
var text = this.getFileContent(this.activeFile.fileName)
|
||||
|
||||
// The text from the start of the line to the end of the file
|
||||
var text = this.getFileContent(this.activeFile.fileName).substring(pos);
|
||||
var pos = this.currentCaretPosition;
|
||||
var startPos = pos, endPos = pos;
|
||||
|
||||
// Truncate to the first newline
|
||||
var newlinePos = text.indexOf('\n');
|
||||
if (newlinePos === -1) {
|
||||
return text;
|
||||
}
|
||||
else {
|
||||
if (text.charAt(newlinePos - 1) === '\r') {
|
||||
newlinePos--;
|
||||
while (startPos > 0) {
|
||||
var ch = text.charCodeAt(startPos - 1);
|
||||
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
|
||||
break;
|
||||
}
|
||||
return text.substr(0, newlinePos);
|
||||
}
|
||||
}
|
||||
|
||||
private getCurrentCaretFilePosition() {
|
||||
var result = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, this.currentCaretPosition);
|
||||
if (result.line >= 0) {
|
||||
result.line++;
|
||||
startPos--;
|
||||
}
|
||||
|
||||
if (result.character >= 0) {
|
||||
result.character++;
|
||||
while (endPos < text.length) {
|
||||
var ch = text.charCodeAt(endPos);
|
||||
|
||||
if (ch === ts.CharacterCodes.carriageReturn || ch === ts.CharacterCodes.lineFeed) {
|
||||
break;
|
||||
}
|
||||
|
||||
endPos++;
|
||||
}
|
||||
|
||||
return result;
|
||||
return text.substring(startPos, endPos);
|
||||
}
|
||||
|
||||
private assertItemInCompletionList(items: ts.CompletionEntry[], name: string, text?: string, documentation?: string, kind?: string) {
|
||||
@@ -2125,7 +2117,7 @@ module FourSlash {
|
||||
}
|
||||
|
||||
private getLineColStringAtPosition(position: number) {
|
||||
var pos = this.languageServiceAdapterHost.positionToZeroBasedLineCol(this.activeFile.fileName, position);
|
||||
var pos = this.languageServiceAdapterHost.positionToLineAndCharacter(this.activeFile.fileName, position);
|
||||
return 'line ' + (pos.line + 1) + ', col ' + pos.character;
|
||||
}
|
||||
|
||||
|
||||
@@ -1185,13 +1185,13 @@ module Harness {
|
||||
}
|
||||
|
||||
export function getMinimalDiagnostic(err: ts.Diagnostic): HarnessDiagnostic {
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterFromPosition(err.start) : { line: 0, character: 0 };
|
||||
var errorLineInfo = err.file ? err.file.getLineAndCharacterOfPosition(err.start) : { line: -1, character: -1 };
|
||||
return {
|
||||
fileName: err.file && err.file.fileName,
|
||||
start: err.start,
|
||||
end: err.start + err.length,
|
||||
line: errorLineInfo.line,
|
||||
character: errorLineInfo.character,
|
||||
line: errorLineInfo.line + 1,
|
||||
character: errorLineInfo.character + 1,
|
||||
message: ts.flattenDiagnosticMessageText(err.messageText, ts.sys.newLine),
|
||||
category: ts.DiagnosticCategory[err.category].toLowerCase(),
|
||||
code: err.code
|
||||
|
||||
@@ -159,32 +159,15 @@ module Harness.LanguageService {
|
||||
public openFile(fileName: string): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1 based index
|
||||
* @param col 1 based index
|
||||
*/
|
||||
public lineColToPosition(fileName: string, line: number, col: number): number {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
assert.isTrue(line >= 1);
|
||||
assert.isTrue(col >= 1);
|
||||
|
||||
return ts.computePositionFromLineAndCharacter(script.lineMap, line, col);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 0 based index
|
||||
* @param col 0 based index
|
||||
*/
|
||||
public positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter {
|
||||
public positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter {
|
||||
var script: ScriptInfo = this.fileNameToScript[fileName];
|
||||
assert.isNotNull(script);
|
||||
|
||||
var result = ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
|
||||
assert.isTrue(result.line >= 1);
|
||||
assert.isTrue(result.character >= 1);
|
||||
return { line: result.line - 1, character: result.character - 1 };
|
||||
return ts.computeLineAndCharacterOfPosition(script.lineMap, position);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -231,8 +214,7 @@ module Harness.LanguageService {
|
||||
getScriptInfo(fileName: string): ScriptInfo { return this.nativeHost.getScriptInfo(fileName); }
|
||||
addScript(fileName: string, content: string): void { this.nativeHost.addScript(fileName, content); }
|
||||
editScript(fileName: string, start: number, end: number, newText: string): void { this.nativeHost.editScript(fileName, start, end, newText); }
|
||||
lineColToPosition(fileName: string, line: number, col: number): number { return this.nativeHost.lineColToPosition(fileName, line, col); }
|
||||
positionToZeroBasedLineCol(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToZeroBasedLineCol(fileName, position); }
|
||||
positionToLineAndCharacter(fileName: string, position: number): ts.LineAndCharacter { return this.nativeHost.positionToLineAndCharacter(fileName, position); }
|
||||
|
||||
getCompilationSettings(): string { return JSON.stringify(this.nativeHost.getCompilationSettings()); }
|
||||
getCancellationToken(): ts.CancellationToken { return this.nativeHost.getCancellationToken(); }
|
||||
@@ -471,10 +453,10 @@ module Harness.LanguageService {
|
||||
args: string[] = [];
|
||||
newLine: string;
|
||||
useCaseSensitiveFileNames: boolean = false;
|
||||
|
||||
constructor(private host: NativeLanguageServiceHost) {
|
||||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
constructor(private host: NativeLanguageServiceHost) {
|
||||
this.newLine = this.host.getNewLine();
|
||||
}
|
||||
|
||||
onMessage(message: string): void {
|
||||
|
||||
@@ -515,9 +497,9 @@ module Harness.LanguageService {
|
||||
return "";
|
||||
}
|
||||
|
||||
exit(exitCode: number): void {
|
||||
}
|
||||
|
||||
exit(exitCode: number): void {
|
||||
}
|
||||
|
||||
createDirectory(directoryName: string): void {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
@@ -529,30 +511,30 @@ module Harness.LanguageService {
|
||||
readDirectory(path: string, extension?: string): string[] {
|
||||
throw new Error("Not implemented Yet.");
|
||||
}
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
}
|
||||
|
||||
close(): void {
|
||||
}
|
||||
|
||||
|
||||
watchFile(fileName: string, callback: (fileName: string) => void): ts.FileWatcher {
|
||||
return { close() { } };
|
||||
}
|
||||
|
||||
close(): void {
|
||||
}
|
||||
|
||||
info(message: string): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
msg(message: string) {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
endGroup(): void {
|
||||
}
|
||||
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
msg(message: string) {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
endGroup(): void {
|
||||
}
|
||||
|
||||
perftrc(message: string): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
startGroup(): void {
|
||||
return this.host.log(message);
|
||||
}
|
||||
|
||||
startGroup(): void {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -85,15 +85,17 @@ class TypeWriterWalker {
|
||||
|
||||
private log(node: ts.Node, type: ts.Type): void {
|
||||
var actualPos = ts.skipTrivia(this.currentSourceFile.text, node.pos);
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterFromPosition(actualPos);
|
||||
var lineAndCharacter = this.currentSourceFile.getLineAndCharacterOfPosition(actualPos);
|
||||
var sourceText = ts.getTextOfNodeFromSourceText(this.currentSourceFile.text, node);
|
||||
|
||||
// If we got an unknown type, we temporarily want to fall back to just pretending the name
|
||||
// (source text) of the node is the type. This is to align with the old typeWriter to make
|
||||
// baseline comparisons easier. In the long term, we will want to just call typeToString
|
||||
this.results.push({
|
||||
line: lineAndCharacter.line - 1,
|
||||
column: lineAndCharacter.character,
|
||||
line: lineAndCharacter.line,
|
||||
// todo(cyrusn): Not sure why column is one-based for type-writer. But I'm preserving
|
||||
// that behavior to prevent having a lot of baselines to fix up.
|
||||
column: lineAndCharacter.character + 1,
|
||||
syntaxKind: node.kind,
|
||||
sourceText: sourceText,
|
||||
type: this.checker.typeToString(type, node.parent, ts.TypeFormatFlags.NoTruncation | ts.TypeFormatFlags.WriteOwnNameForAnyLike)
|
||||
|
||||
@@ -47,14 +47,14 @@ module ts.server {
|
||||
}
|
||||
|
||||
private lineColToPosition(fileName: string, lineCol: protocol.Location): number {
|
||||
return ts.computePositionFromLineAndCharacter(this.getLineMap(fileName), lineCol.line, lineCol.col);
|
||||
return ts.computePositionOfLineAndCharacter(this.getLineMap(fileName), lineCol.line - 1, lineCol.col - 1);
|
||||
}
|
||||
|
||||
private positionToOneBasedLineCol(fileName: string, position: number): protocol.Location {
|
||||
var lineCol = ts.computeLineAndCharacterOfPosition(this.getLineMap(fileName), position);
|
||||
return {
|
||||
line: lineCol.line,
|
||||
col: lineCol.character
|
||||
line: lineCol.line + 1,
|
||||
col: lineCol.character + 1
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -14,17 +14,17 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
var tokenAtLocation = getTokenAtPosition(sourceFile, position);
|
||||
var lineOfPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
|
||||
var lineOfPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getStart()).line > lineOfPosition) {
|
||||
// Get previous token if the token is returned starts on new line
|
||||
// eg: var x =10; |--- curser is here
|
||||
// eg: var x =10; |--- cursor is here
|
||||
// var y = 10;
|
||||
// token at position will return var keyword on second line as the token but we would like to use
|
||||
// token on same line if trailing trivia (comments or white spaces on same line) part of the last token on that line
|
||||
tokenAtLocation = findPrecedingToken(tokenAtLocation.pos, sourceFile);
|
||||
|
||||
// Its a blank line
|
||||
if (!tokenAtLocation || sourceFile.getLineAndCharacterFromPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
|
||||
if (!tokenAtLocation || sourceFile.getLineAndCharacterOfPosition(tokenAtLocation.getEnd()).line !== lineOfPosition) {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ module ts.BreakpointResolver {
|
||||
}
|
||||
|
||||
function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan {
|
||||
if (node && lineOfPosition === sourceFile.getLineAndCharacterFromPosition(node.getStart()).line) {
|
||||
if (node && lineOfPosition === sourceFile.getLineAndCharacterOfPosition(node.getStart()).line) {
|
||||
return spanInNode(node);
|
||||
}
|
||||
return spanInNode(otherwiseOnNode);
|
||||
|
||||
@@ -67,8 +67,8 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function formatOnEnter(position: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
if (line === 1) {
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
if (line === 0) {
|
||||
return [];
|
||||
}
|
||||
// get the span for the previous\current line
|
||||
@@ -100,7 +100,7 @@ module ts.formatting {
|
||||
export function formatSelection(start: number, end: number, sourceFile: SourceFile, rulesProvider: RulesProvider, options: FormatCodeOptions): TextChange[] {
|
||||
// format from the beginning of the line
|
||||
var span = {
|
||||
pos: getStartLinePositionForPosition(start, sourceFile),
|
||||
pos: getLineStartPositionForPosition(start, sourceFile),
|
||||
end: end
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, FormattingRequestKind.FormatSelection);
|
||||
@@ -112,7 +112,7 @@ module ts.formatting {
|
||||
return [];
|
||||
}
|
||||
var span = {
|
||||
pos: getStartLinePositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
pos: getLineStartPositionForPosition(parent.getStart(sourceFile), sourceFile),
|
||||
end: parent.end
|
||||
};
|
||||
return formatSpan(span, sourceFile, options, rulesProvider, requestKind);
|
||||
@@ -283,7 +283,7 @@ module ts.formatting {
|
||||
var previousLine = Constants.Unknown;
|
||||
var childKind = SyntaxKind.Unknown;
|
||||
while (n) {
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile)).line;
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile)).line;
|
||||
if (previousLine !== Constants.Unknown && line !== previousLine) {
|
||||
break;
|
||||
}
|
||||
@@ -327,7 +327,7 @@ module ts.formatting {
|
||||
formattingScanner.advance();
|
||||
|
||||
if (formattingScanner.isOnToken()) {
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line;
|
||||
var delta = getOwnOrInheritedDelta(enclosingNode, options, sourceFile);
|
||||
processNode(enclosingNode, enclosingNode, startLine, initialIndentation, delta);
|
||||
}
|
||||
@@ -357,8 +357,8 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
else {
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(startPos).line;
|
||||
var startLinePosition = getStartLinePositionForPosition(startPos, sourceFile);
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(startPos).line;
|
||||
var startLinePosition = getLineStartPositionForPosition(startPos, sourceFile);
|
||||
var column = SmartIndenter.findFirstNonWhitespaceColumn(startLinePosition, startPos, sourceFile, options);
|
||||
if (startLine !== parentStartLine || startPos === column) {
|
||||
return column
|
||||
@@ -521,7 +521,7 @@ module ts.formatting {
|
||||
|
||||
var childStartPos = child.getStart(sourceFile);
|
||||
|
||||
var childStart = sourceFile.getLineAndCharacterFromPosition(childStartPos);
|
||||
var childStart = sourceFile.getLineAndCharacterOfPosition(childStartPos);
|
||||
|
||||
// if child is a list item - try to get its indentation
|
||||
var childIndentationAmount = Constants.Unknown;
|
||||
@@ -594,7 +594,7 @@ module ts.formatting {
|
||||
}
|
||||
else if (tokenInfo.token.kind === listStartToken) {
|
||||
// consume list start token
|
||||
startLine = sourceFile.getLineAndCharacterFromPosition(tokenInfo.token.pos).line;
|
||||
startLine = sourceFile.getLineAndCharacterOfPosition(tokenInfo.token.pos).line;
|
||||
var indentation =
|
||||
computeIndentation(tokenInfo.token, startLine, Constants.Unknown, parent, parentDynamicIndentation, startLine);
|
||||
|
||||
@@ -641,7 +641,7 @@ module ts.formatting {
|
||||
var lineAdded: boolean;
|
||||
var isTokenInRange = rangeContainsRange(originalRange, currentTokenInfo.token);
|
||||
|
||||
var tokenStart = sourceFile.getLineAndCharacterFromPosition(currentTokenInfo.token.pos);
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(currentTokenInfo.token.pos);
|
||||
if (isTokenInRange) {
|
||||
var rangeHasError = rangeContainsError(currentTokenInfo.token);
|
||||
// save prevStartLine since processRange will overwrite this value with current ones
|
||||
@@ -674,7 +674,7 @@ module ts.formatting {
|
||||
continue;
|
||||
}
|
||||
|
||||
var triviaStartLine = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos).line;
|
||||
var triviaStartLine = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos).line;
|
||||
switch (triviaItem.kind) {
|
||||
case SyntaxKind.MultiLineCommentTrivia:
|
||||
var commentIndentation = dynamicIndentation.getIndentationForComment(currentTokenInfo.token.kind);
|
||||
@@ -712,7 +712,7 @@ module ts.formatting {
|
||||
for (var i = 0, len = trivia.length; i < len; ++i) {
|
||||
var triviaItem = trivia[i];
|
||||
if (isComment(triviaItem.kind) && rangeContainsRange(originalRange, triviaItem)) {
|
||||
var triviaItemStart = sourceFile.getLineAndCharacterFromPosition(triviaItem.pos);
|
||||
var triviaItemStart = sourceFile.getLineAndCharacterOfPosition(triviaItem.pos);
|
||||
processRange(triviaItem, triviaItemStart, parent, contextNode, dynamicIndentation);
|
||||
}
|
||||
}
|
||||
@@ -729,7 +729,7 @@ module ts.formatting {
|
||||
if (!rangeHasError && !previousRangeHasError) {
|
||||
if (!previousRange) {
|
||||
// trim whitespaces starting from the beginning of the span up to the current line
|
||||
var originalStart = sourceFile.getLineAndCharacterFromPosition(originalRange.pos);
|
||||
var originalStart = sourceFile.getLineAndCharacterOfPosition(originalRange.pos);
|
||||
trimTrailingWhitespacesForLines(originalStart.line, rangeStart.line);
|
||||
}
|
||||
else {
|
||||
@@ -807,18 +807,18 @@ module ts.formatting {
|
||||
recordReplace(pos, 0, indentationString);
|
||||
}
|
||||
else {
|
||||
var tokenStart = sourceFile.getLineAndCharacterFromPosition(pos);
|
||||
if (indentation !== tokenStart.character - 1) {
|
||||
var tokenStart = sourceFile.getLineAndCharacterOfPosition(pos);
|
||||
if (indentation !== tokenStart.character) {
|
||||
var startLinePosition = getStartPositionOfLine(tokenStart.line, sourceFile);
|
||||
recordReplace(startLinePosition, tokenStart.character - 1, indentationString);
|
||||
recordReplace(startLinePosition, tokenStart.character, indentationString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function indentMultilineComment(commentRange: TextRange, indentation: number, firstLineIsIndented: boolean) {
|
||||
// split comment in lines
|
||||
var startLine = sourceFile.getLineAndCharacterFromPosition(commentRange.pos).line;
|
||||
var endLine = sourceFile.getLineAndCharacterFromPosition(commentRange.end).line;
|
||||
var startLine = sourceFile.getLineAndCharacterOfPosition(commentRange.pos).line;
|
||||
var endLine = sourceFile.getLineAndCharacterOfPosition(commentRange.end).line;
|
||||
|
||||
if (startLine === endLine) {
|
||||
if (!firstLineIsIndented) {
|
||||
|
||||
@@ -71,8 +71,8 @@ module ts.formatting {
|
||||
|
||||
public TokensAreOnSameLine(): boolean {
|
||||
if (this.tokensAreOnSameLine === undefined) {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(this.currentTokenSpan.pos).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(this.nextTokenSpan.pos).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(this.currentTokenSpan.pos).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(this.nextTokenSpan.pos).line;
|
||||
this.tokensAreOnSameLine = (startLine == endLine);
|
||||
}
|
||||
|
||||
@@ -96,8 +96,8 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
private NodeIsOnOneLine(node: Node): boolean {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(node.getStart(this.sourceFile)).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(node.getEnd()).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(node.getStart(this.sourceFile)).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(node.getEnd()).line;
|
||||
return startLine == endLine;
|
||||
}
|
||||
|
||||
@@ -105,8 +105,8 @@ module ts.formatting {
|
||||
var openBrace = findChildOfKind(node, SyntaxKind.OpenBraceToken, this.sourceFile);
|
||||
var closeBrace = findChildOfKind(node, SyntaxKind.CloseBraceToken, this.sourceFile);
|
||||
if (openBrace && closeBrace) {
|
||||
var startLine = this.sourceFile.getLineAndCharacterFromPosition(openBrace.getEnd()).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterFromPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
var startLine = this.sourceFile.getLineAndCharacterOfPosition(openBrace.getEnd()).line;
|
||||
var endLine = this.sourceFile.getLineAndCharacterOfPosition(closeBrace.getStart(this.sourceFile)).line;
|
||||
return startLine === endLine;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -24,7 +24,7 @@ module ts.formatting {
|
||||
return 0;
|
||||
}
|
||||
|
||||
var lineAtPosition = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
var lineAtPosition = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
|
||||
if (precedingToken.kind === SyntaxKind.CommaToken && precedingToken.parent.kind !== SyntaxKind.BinaryExpression) {
|
||||
// previous token is comma that separates items in list - find the previous item and try to derive indentation from it
|
||||
@@ -74,7 +74,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
export function getIndentationForNode(n: Node, ignoreActualIndentationRange: TextRange, sourceFile: SourceFile, options: FormatCodeOptions): number {
|
||||
var start = sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
|
||||
var start = sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
return getIndentationForNodeWorker(n, start, ignoreActualIndentationRange, /*indentationDelta*/ 0, sourceFile, options);
|
||||
}
|
||||
|
||||
@@ -135,10 +135,10 @@ module ts.formatting {
|
||||
function getParentStart(parent: Node, child: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
var containingList = getContainingList(child, sourceFile);
|
||||
if (containingList) {
|
||||
return sourceFile.getLineAndCharacterFromPosition(containingList.pos);
|
||||
return sourceFile.getLineAndCharacterOfPosition(containingList.pos);
|
||||
}
|
||||
|
||||
return sourceFile.getLineAndCharacterFromPosition(parent.getStart(sourceFile));
|
||||
return sourceFile.getLineAndCharacterOfPosition(parent.getStart(sourceFile));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -204,7 +204,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function getStartLineAndCharacterForNode(n: Node, sourceFile: SourceFile): LineAndCharacter {
|
||||
return sourceFile.getLineAndCharacterFromPosition(n.getStart(sourceFile));
|
||||
return sourceFile.getLineAndCharacterOfPosition(n.getStart(sourceFile));
|
||||
}
|
||||
|
||||
function positionBelongsToNode(candidate: Node, position: number, sourceFile: SourceFile): boolean {
|
||||
@@ -279,7 +279,6 @@ module ts.formatting {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function deriveActualIndentationFromList(list: Node[], index: number, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
Debug.assert(index >= 0 && index < list.length);
|
||||
var node = list[index];
|
||||
@@ -292,7 +291,7 @@ module ts.formatting {
|
||||
continue;
|
||||
}
|
||||
// skip list items that ends on the same line with the current list element
|
||||
var prevEndLine = sourceFile.getLineAndCharacterFromPosition(list[i].end).line;
|
||||
var prevEndLine = sourceFile.getLineAndCharacterOfPosition(list[i].end).line;
|
||||
if (prevEndLine !== lineAndCharacter.line) {
|
||||
return findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter, sourceFile, options);
|
||||
}
|
||||
@@ -303,7 +302,7 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function findColumnForFirstNonWhitespaceCharacterInLine(lineAndCharacter: LineAndCharacter, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
var lineStart = sourceFile.getPositionFromLineAndCharacter(lineAndCharacter.line, 1);
|
||||
var lineStart = sourceFile.getPositionOfLineAndCharacter(lineAndCharacter.line, 0);
|
||||
return findFirstNonWhitespaceColumn(lineStart, lineStart + lineAndCharacter.character, sourceFile, options);
|
||||
}
|
||||
|
||||
|
||||
@@ -62,9 +62,9 @@ module ts {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
|
||||
@@ -613,7 +613,7 @@ module ts {
|
||||
}
|
||||
|
||||
if (paramHelpStringMargin === undefined) {
|
||||
paramHelpStringMargin = sourceFile.getLineAndCharacterFromPosition(firstLineParamHelpStringPos).character - 1;
|
||||
paramHelpStringMargin = sourceFile.getLineAndCharacterOfPosition(firstLineParamHelpStringPos).character;
|
||||
}
|
||||
|
||||
// Now consume white spaces max
|
||||
@@ -751,16 +751,16 @@ module ts {
|
||||
return updateSourceFile(this, newText, textChangeRange);
|
||||
}
|
||||
|
||||
public getLineAndCharacterFromPosition(position: number): LineAndCharacter {
|
||||
return getLineAndCharacterOfPosition(this, position);
|
||||
public getLineAndCharacterOfPosition(position: number): LineAndCharacter {
|
||||
return ts.getLineAndCharacterOfPosition(this, position);
|
||||
}
|
||||
|
||||
public getLineStarts(): number[] {
|
||||
return getLineStarts(this);
|
||||
}
|
||||
|
||||
public getPositionFromLineAndCharacter(line: number, character: number): number {
|
||||
return getPositionFromLineAndCharacter(this, line, character);
|
||||
public getPositionOfLineAndCharacter(line: number, character: number): number {
|
||||
return ts.getPositionOfLineAndCharacter(this, line, character);
|
||||
}
|
||||
|
||||
public getNamedDeclarations() {
|
||||
|
||||
@@ -6,12 +6,11 @@ module ts {
|
||||
}
|
||||
|
||||
export function getEndLinePosition(line: number, sourceFile: SourceFile): number {
|
||||
Debug.assert(line >= 1);
|
||||
Debug.assert(line >= 0);
|
||||
var lineStarts = sourceFile.getLineStarts();
|
||||
|
||||
// lines returned by SourceFile.getLineAndCharacterForPosition are 1-based
|
||||
var lineIndex = line - 1;
|
||||
if (lineIndex === lineStarts.length - 1) {
|
||||
var lineIndex = line;
|
||||
if (lineIndex + 1 === lineStarts.length) {
|
||||
// last line - return EOF
|
||||
return sourceFile.text.length - 1;
|
||||
}
|
||||
@@ -32,15 +31,10 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
export function getStartPositionOfLine(line: number, sourceFile: SourceFile): number {
|
||||
Debug.assert(line >= 1);
|
||||
return sourceFile.getLineStarts()[line - 1];
|
||||
}
|
||||
|
||||
export function getStartLinePositionForPosition(position: number, sourceFile: SourceFile): number {
|
||||
export function getLineStartPositionForPosition(position: number, sourceFile: SourceFile): number {
|
||||
var lineStarts = sourceFile.getLineStarts();
|
||||
var line = sourceFile.getLineAndCharacterFromPosition(position).line;
|
||||
return lineStarts[line - 1];
|
||||
var line = sourceFile.getLineAndCharacterOfPosition(position).line;
|
||||
return lineStarts[line];
|
||||
}
|
||||
|
||||
export function rangeContainsRange(r1: TextRange, r2: TextRange): boolean {
|
||||
|
||||
@@ -21,8 +21,8 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
});
|
||||
|
||||
var exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||
@@ -1392,8 +1392,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1477,9 +1477,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -1955,8 +1955,8 @@ function compile(fileNames, options) {
|
||||
var emitResult = program.emit();
|
||||
var allDiagnostics = ts.getPreEmitDiagnostics(program).concat(emitResult.diagnostics);
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL));
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(diagnostic.file.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL));
|
||||
});
|
||||
var exitCode = emitResult.emitSkipped ? 1 : 0;
|
||||
console.log("Process exiting with code '" + exitCode + "'.");
|
||||
|
||||
@@ -56,27 +56,27 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>diagnostics : ts.Diagnostic[]
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); }) : void
|
||||
>allDiagnostics.forEach(diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic => { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`); } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic
|
||||
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.start : number
|
||||
>diagnostic : ts.Diagnostic
|
||||
>start : number
|
||||
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`) : any
|
||||
console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`);
|
||||
>console.log(`${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, os.EOL)}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
@@ -85,9 +85,11 @@ export function compile(fileNames: string[], options: ts.CompilerOptions): void
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>fileName : string
|
||||
>lineChar.line + 1 : number
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
>lineChar.character + 1 : number
|
||||
>lineChar.character : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>character : number
|
||||
@@ -4393,15 +4395,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -4760,16 +4762,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -51,8 +51,8 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
}
|
||||
|
||||
function report(node: ts.Node, message: string) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1423,8 +1423,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1508,9 +1508,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -2012,8 +2012,8 @@ function delint(sourceFile) {
|
||||
ts.forEachChild(node, delintNode);
|
||||
}
|
||||
function report(node, message) {
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
console.log(sourceFile.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + message);
|
||||
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
console.log(sourceFile.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + message);
|
||||
}
|
||||
}
|
||||
exports.delint = delint;
|
||||
|
||||
@@ -226,28 +226,30 @@ export function delint(sourceFile: ts.SourceFile) {
|
||||
>Node : ts.Node
|
||||
>message : string
|
||||
|
||||
var lineChar = sourceFile.getLineAndCharacterFromPosition(node.getStart());
|
||||
var lineChar = sourceFile.getLineAndCharacterOfPosition(node.getStart());
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterFromPosition(node.getStart()) : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterOfPosition(node.getStart()) : ts.LineAndCharacter
|
||||
>sourceFile.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>sourceFile : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>node.getStart() : number
|
||||
>node.getStart : (sourceFile?: ts.SourceFile) => number
|
||||
>node : ts.Node
|
||||
>getStart : (sourceFile?: ts.SourceFile) => number
|
||||
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`)
|
||||
>console.log(`${sourceFile.fileName} (${lineChar.line},${lineChar.character}): ${message}`) : any
|
||||
console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`)
|
||||
>console.log(`${sourceFile.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${message}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
>sourceFile.fileName : string
|
||||
>sourceFile : ts.SourceFile
|
||||
>fileName : string
|
||||
>lineChar.line + 1 : number
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
>lineChar.character + 1 : number
|
||||
>lineChar.character : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>character : number
|
||||
@@ -4539,15 +4541,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -4906,16 +4908,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
|
||||
+ ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
@@ -1424,8 +1424,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1509,9 +1509,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -2014,7 +2014,7 @@ function transform(contents, compilerOptions) {
|
||||
return {
|
||||
outputs: outputs,
|
||||
errors: errors.map(function (e) {
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL);
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
>diagnostics : ts.Diagnostic[]
|
||||
|
||||
return {
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) } : { outputs: any[]; errors: string[]; }
|
||||
>{ outputs: outputs, errors: errors.map(function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) } : { outputs: any[]; errors: string[]; }
|
||||
|
||||
outputs: outputs,
|
||||
>outputs : any[]
|
||||
@@ -185,30 +185,32 @@ function transform(contents: string, compilerOptions: ts.CompilerOptions = {}) {
|
||||
|
||||
errors: errors.map(function (e) {
|
||||
>errors : string[]
|
||||
>errors.map(function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) : string[]
|
||||
>errors.map(function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); }) : string[]
|
||||
>errors.map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>errors : ts.Diagnostic[]
|
||||
>map : <U>(callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => U, thisArg?: any) => U[]
|
||||
>function (e) { return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); } : (e: ts.Diagnostic) => string
|
||||
>function (e) { return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL); } : (e: ts.Diagnostic) => string
|
||||
>e : ts.Diagnostic
|
||||
|
||||
return e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): "
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line + "): " : string
|
||||
>e.file.fileName + "(" + e.file.getLineAndCharacterFromPosition(e.start).line : string
|
||||
return e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): "
|
||||
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " + ts.flattenDiagnosticMessageText(e.messageText, os.EOL) : string
|
||||
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) + "): " : string
|
||||
>e.file.fileName + "(" + (e.file.getLineAndCharacterOfPosition(e.start).line + 1) : string
|
||||
>e.file.fileName + "(" : string
|
||||
>e.file.fileName : string
|
||||
>e.file : ts.SourceFile
|
||||
>e : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>fileName : string
|
||||
>e.file.getLineAndCharacterFromPosition(e.start).line : number
|
||||
>e.file.getLineAndCharacterFromPosition(e.start) : ts.LineAndCharacter
|
||||
>e.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>(e.file.getLineAndCharacterOfPosition(e.start).line + 1) : number
|
||||
>e.file.getLineAndCharacterOfPosition(e.start).line + 1 : number
|
||||
>e.file.getLineAndCharacterOfPosition(e.start).line : number
|
||||
>e.file.getLineAndCharacterOfPosition(e.start) : ts.LineAndCharacter
|
||||
>e.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>e.file : ts.SourceFile
|
||||
>e : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>e.start : number
|
||||
>e : ts.Diagnostic
|
||||
>start : number
|
||||
@@ -4489,15 +4491,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -4856,16 +4858,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -87,8 +87,8 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
}
|
||||
else {
|
||||
console.log(` Error: ${diagnostic.messageText}`);
|
||||
@@ -1461,8 +1461,8 @@ declare module "typescript" {
|
||||
}
|
||||
function tokenToString(t: SyntaxKind): string;
|
||||
function computeLineStarts(text: string): number[];
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
function getLineStarts(sourceFile: SourceFile): number[];
|
||||
function computeLineAndCharacterOfPosition(lineStarts: number[], position: number): {
|
||||
line: number;
|
||||
@@ -1546,9 +1546,9 @@ declare module "typescript" {
|
||||
scriptSnapshot: IScriptSnapshot;
|
||||
nameTable: Map<string>;
|
||||
getNamedDeclarations(): Declaration[];
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
getLineStarts(): number[];
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
update(newText: string, textChangeRange: TextChangeRange): SourceFile;
|
||||
}
|
||||
/**
|
||||
@@ -2074,8 +2074,8 @@ function watch(rootFileNames, options) {
|
||||
var allDiagnostics = services.getCompilerOptionsDiagnostics().concat(services.getSyntacticDiagnostics(fileName)).concat(services.getSemanticDiagnostics(fileName));
|
||||
allDiagnostics.forEach(function (diagnostic) {
|
||||
if (diagnostic.file) {
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
console.log(" Error " + diagnostic.file.fileName + " (" + lineChar.line + "," + lineChar.character + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
console.log(" Error " + diagnostic.file.fileName + " (" + (lineChar.line + 1) + "," + (lineChar.character + 1) + "): " + ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n"));
|
||||
}
|
||||
else {
|
||||
console.log(" Error: " + diagnostic.messageText);
|
||||
|
||||
@@ -317,11 +317,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>fileName : string
|
||||
|
||||
allDiagnostics.forEach(diagnostic => {
|
||||
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
|
||||
>allDiagnostics.forEach(diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } }) : void
|
||||
>allDiagnostics.forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>allDiagnostics : ts.Diagnostic[]
|
||||
>forEach : (callbackfn: (value: ts.Diagnostic, index: number, array: ts.Diagnostic[]) => void, thisArg?: any) => void
|
||||
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic => { if (diagnostic.file) { var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start); console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`); } else { console.log(` Error: ${diagnostic.messageText}`); } } : (diagnostic: ts.Diagnostic) => void
|
||||
>diagnostic : ts.Diagnostic
|
||||
|
||||
if (diagnostic.file) {
|
||||
@@ -329,20 +329,20 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
|
||||
var lineChar = diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start);
|
||||
var lineChar = diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start);
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition(diagnostic.start) : ts.LineAndCharacter
|
||||
>diagnostic.file.getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.file : ts.SourceFile
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>getLineAndCharacterFromPosition : (pos: number) => ts.LineAndCharacter
|
||||
>getLineAndCharacterOfPosition : (pos: number) => ts.LineAndCharacter
|
||||
>diagnostic.start : number
|
||||
>diagnostic : ts.Diagnostic
|
||||
>start : number
|
||||
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
>console.log(` Error ${diagnostic.file.fileName} (${lineChar.line},${lineChar.character}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`) : any
|
||||
console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`);
|
||||
>console.log(` Error ${diagnostic.file.fileName} (${lineChar.line + 1},${lineChar.character + 1}): ${ts.flattenDiagnosticMessageText(diagnostic.messageText, "\n")}`) : any
|
||||
>console.log : any
|
||||
>console : any
|
||||
>log : any
|
||||
@@ -351,9 +351,11 @@ function watch(rootFileNames: string[], options: ts.CompilerOptions) {
|
||||
>diagnostic : ts.Diagnostic
|
||||
>file : ts.SourceFile
|
||||
>fileName : string
|
||||
>lineChar.line + 1 : number
|
||||
>lineChar.line : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>line : number
|
||||
>lineChar.character + 1 : number
|
||||
>lineChar.character : number
|
||||
>lineChar : ts.LineAndCharacter
|
||||
>character : number
|
||||
@@ -4662,15 +4664,15 @@ declare module "typescript" {
|
||||
>computeLineStarts : (text: string) => number[]
|
||||
>text : string
|
||||
|
||||
function getPositionFromLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
function getPositionOfLineAndCharacter(sourceFile: SourceFile, line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (sourceFile: SourceFile, line: number, character: number) => number
|
||||
>sourceFile : SourceFile
|
||||
>SourceFile : SourceFile
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
function computePositionFromLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionFromLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
function computePositionOfLineAndCharacter(lineStarts: number[], line: number, character: number): number;
|
||||
>computePositionOfLineAndCharacter : (lineStarts: number[], line: number, character: number) => number
|
||||
>lineStarts : number[]
|
||||
>line : number
|
||||
>character : number
|
||||
@@ -5029,16 +5031,16 @@ declare module "typescript" {
|
||||
>getNamedDeclarations : () => Declaration[]
|
||||
>Declaration : Declaration
|
||||
|
||||
getLineAndCharacterFromPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterFromPosition : (pos: number) => LineAndCharacter
|
||||
getLineAndCharacterOfPosition(pos: number): LineAndCharacter;
|
||||
>getLineAndCharacterOfPosition : (pos: number) => LineAndCharacter
|
||||
>pos : number
|
||||
>LineAndCharacter : LineAndCharacter
|
||||
|
||||
getLineStarts(): number[];
|
||||
>getLineStarts : () => number[]
|
||||
|
||||
getPositionFromLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionFromLineAndCharacter : (line: number, character: number) => number
|
||||
getPositionOfLineAndCharacter(line: number, character: number): number;
|
||||
>getPositionOfLineAndCharacter : (line: number, character: number) => number
|
||||
>line : number
|
||||
>character : number
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames10.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames10_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
+2
-2
@@ -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;
|
||||
@@ -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
|
||||
}
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames11.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames11_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
+2
-2
@@ -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;
|
||||
@@ -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
|
||||
}
|
||||
+12
-12
@@ -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;
|
||||
@@ -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.
|
||||
}
|
||||
+2
-2
@@ -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;
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames13.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames13_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
+2
-2
@@ -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;
|
||||
@@ -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
|
||||
}
|
||||
+7
-7
@@ -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]() {}
|
||||
+2
-2
@@ -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'.
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
+3
-3
@@ -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;
|
||||
+2
-2
@@ -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'.
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames16.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames16_ES5.ts ===
|
||||
var s: string;
|
||||
>s : string
|
||||
|
||||
+2
-2
@@ -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;
|
||||
@@ -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
|
||||
}
|
||||
+7
-7
@@ -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;}
|
||||
+2
-2
@@ -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'.
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames18.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames18_ES5.ts ===
|
||||
function foo() {
|
||||
>foo : () => void
|
||||
|
||||
+2
-2
@@ -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
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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
|
||||
@@ -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.
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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 = {
|
||||
@@ -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
-1
@@ -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} : {}
|
||||
+2
-2
@@ -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;
|
||||
@@ -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
|
||||
};
|
||||
@@ -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
-1
@@ -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} : {}
|
||||
@@ -0,0 +1,9 @@
|
||||
//// [computedPropertyNames20_ES6.ts]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
}
|
||||
|
||||
//// [computedPropertyNames20_ES6.js]
|
||||
var obj = {
|
||||
[this.bar]: 0
|
||||
};
|
||||
@@ -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
|
||||
}
|
||||
+2
-2
@@ -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;
|
||||
+2
-2
@@ -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.
|
||||
}
|
||||
@@ -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;
|
||||
})();
|
||||
@@ -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
-1
@@ -1,4 +1,4 @@
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames22.ts ===
|
||||
=== tests/cases/conformance/es6/computedProperties/computedPropertyNames22_ES5.ts ===
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
+2
-2
@@ -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() {
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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;
|
||||
@@ -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.
|
||||
]() { }
|
||||
}
|
||||
+2
-2
@@ -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() {
|
||||
}
|
||||
+2
-2
@@ -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;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user