mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into inlineSourceMaps
This commit is contained in:
+110
-64
@@ -2078,15 +2078,20 @@ module ts {
|
||||
}
|
||||
}
|
||||
else {
|
||||
// For an array binding element the specified or inferred type of the parent must be an array-like type
|
||||
if (!isArrayLikeType(parentType)) {
|
||||
error(pattern, Diagnostics.Type_0_is_not_an_array_type, typeToString(parentType));
|
||||
return unknownType;
|
||||
}
|
||||
// This elementType will be used if the specific property corresponding to this index is not
|
||||
// present (aka the tuple element property). This call also checks that the parentType is in
|
||||
// fact an iterable or array (depending on target language).
|
||||
let elementType = checkIteratedTypeOrElementType(parentType, pattern, /*allowStringInput*/ false);
|
||||
if (!declaration.dotDotDotToken) {
|
||||
if (elementType.flags & TypeFlags.Any) {
|
||||
return elementType;
|
||||
}
|
||||
|
||||
// Use specific property type when parent is a tuple or numeric index type when parent is an array
|
||||
let propName = "" + indexOf(pattern.elements, declaration);
|
||||
type = isTupleLikeType(parentType) ? getTypeOfPropertyOfType(parentType, propName) : getIndexTypeOfType(parentType, IndexKind.Number);
|
||||
type = isTupleLikeType(parentType)
|
||||
? getTypeOfPropertyOfType(parentType, propName)
|
||||
: elementType;
|
||||
if (!type) {
|
||||
if (isTupleType(parentType)) {
|
||||
error(declaration, Diagnostics.Tuple_type_0_with_length_1_cannot_be_assigned_to_tuple_with_length_2, typeToString(parentType), (<TupleType>parentType).elementTypes.length, pattern.elements.length);
|
||||
@@ -2099,7 +2104,7 @@ module ts {
|
||||
}
|
||||
else {
|
||||
// Rest element has an array type with the same element type as the parent type
|
||||
type = createArrayType(getIndexTypeOfType(parentType, IndexKind.Number));
|
||||
type = createArrayType(elementType);
|
||||
}
|
||||
}
|
||||
return type;
|
||||
@@ -2188,7 +2193,34 @@ module ts {
|
||||
hasSpreadElement = true;
|
||||
}
|
||||
});
|
||||
return !elementTypes.length ? anyArrayType : hasSpreadElement ? createArrayType(getUnionType(elementTypes)) : createTupleType(elementTypes);
|
||||
if (!elementTypes.length) {
|
||||
return languageVersion >= ScriptTarget.ES6 ? createIterableType(anyType) : anyArrayType;
|
||||
}
|
||||
else if (hasSpreadElement) {
|
||||
let unionOfElements = getUnionType(elementTypes);
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
// If the user has something like:
|
||||
//
|
||||
// function fun(...[a, ...b]) { }
|
||||
//
|
||||
// Normally, in ES6, the implied type of an array binding pattern with a rest element is
|
||||
// an iterable. However, there is a requirement in our type system that all rest
|
||||
// parameters be array types. To satisfy this, we have an exception to the rule that
|
||||
// says the type of an array binding pattern with a rest element is an array type
|
||||
// if it is *itself* in a rest parameter. It will still be compatible with a spreaded
|
||||
// iterable argument, but within the function it will be an array.
|
||||
let parent = pattern.parent;
|
||||
let isRestParameter = parent.kind === SyntaxKind.Parameter &&
|
||||
pattern === (<ParameterDeclaration>parent).name &&
|
||||
(<ParameterDeclaration>parent).dotDotDotToken !== undefined;
|
||||
return isRestParameter ? createArrayType(unionOfElements) : createIterableType(unionOfElements);
|
||||
}
|
||||
|
||||
return createArrayType(unionOfElements);
|
||||
}
|
||||
|
||||
// If the pattern has at least one element, and no rest element, then it should imply a tuple type.
|
||||
return createTupleType(elementTypes);
|
||||
}
|
||||
|
||||
// Return the type implied by a binding pattern. This is the type implied purely by the binding pattern itself
|
||||
@@ -3461,6 +3493,10 @@ module ts {
|
||||
return globalESSymbolConstructorSymbol || (globalESSymbolConstructorSymbol = getGlobalValueSymbol("Symbol"));
|
||||
}
|
||||
|
||||
function createIterableType(elementType: Type): Type {
|
||||
return globalIterableType !== emptyObjectType ? createTypeReference(<GenericType>globalIterableType, [elementType]) : emptyObjectType;
|
||||
}
|
||||
|
||||
function createArrayType(elementType: Type): Type {
|
||||
// globalArrayType will be undefined if we get here during creation of the Array type. This for example happens if
|
||||
// user code augments the Array type with call or construct signatures that have an array type as the return type.
|
||||
@@ -5600,7 +5636,7 @@ module ts {
|
||||
}
|
||||
}
|
||||
|
||||
if (container.kind === SyntaxKind.ComputedPropertyName) {
|
||||
if (container && container.kind === SyntaxKind.ComputedPropertyName) {
|
||||
error(node, Diagnostics.super_cannot_be_referenced_in_a_computed_property_name);
|
||||
}
|
||||
else if (isCallExpression) {
|
||||
@@ -5968,12 +6004,14 @@ module ts {
|
||||
}
|
||||
|
||||
function checkSpreadElementExpression(node: SpreadElementExpression, contextualMapper?: TypeMapper): Type {
|
||||
let type = checkExpressionCached(node.expression, contextualMapper);
|
||||
if (!isArrayLikeType(type)) {
|
||||
error(node.expression, Diagnostics.Type_0_is_not_an_array_type, typeToString(type));
|
||||
return unknownType;
|
||||
}
|
||||
return type;
|
||||
// It is usually not safe to call checkExpressionCached if we can be contextually typing.
|
||||
// You can tell that we are contextually typing because of the contextualMapper parameter.
|
||||
// While it is true that a spread element can have a contextual type, it does not do anything
|
||||
// with this type. It is neither affected by it, nor does it propagate it to its operand.
|
||||
// So the fact that contextualMapper is passed is not important, because the operand of a spread
|
||||
// element is not contextually typed.
|
||||
let arrayOrIterableType = checkExpressionCached(node.expression, contextualMapper);
|
||||
return checkIteratedTypeOrElementType(arrayOrIterableType, node.expression, /*allowStringInput*/ false);
|
||||
}
|
||||
|
||||
function checkArrayLiteral(node: ArrayLiteralExpression, contextualMapper?: TypeMapper): Type {
|
||||
@@ -5981,18 +6019,13 @@ module ts {
|
||||
if (!elements.length) {
|
||||
return createArrayType(undefinedType);
|
||||
}
|
||||
let hasSpreadElement: boolean = false;
|
||||
let hasSpreadElement = false;
|
||||
let elementTypes: Type[] = [];
|
||||
forEach(elements, e => {
|
||||
for (let e of elements) {
|
||||
let type = checkExpression(e, contextualMapper);
|
||||
if (e.kind === SyntaxKind.SpreadElementExpression) {
|
||||
elementTypes.push(getIndexTypeOfType(type, IndexKind.Number) || anyType);
|
||||
hasSpreadElement = true;
|
||||
}
|
||||
else {
|
||||
elementTypes.push(type);
|
||||
}
|
||||
});
|
||||
elementTypes.push(type);
|
||||
hasSpreadElement = hasSpreadElement || e.kind === SyntaxKind.SpreadElementExpression;
|
||||
}
|
||||
if (!hasSpreadElement) {
|
||||
let contextualType = getContextualType(node);
|
||||
if (contextualType && contextualTypeIsTupleLikeType(contextualType) || isAssignmentTarget(node)) {
|
||||
@@ -6615,7 +6648,7 @@ module ts {
|
||||
for (let i = 0; i < args.length; i++) {
|
||||
let arg = args[i];
|
||||
if (arg.kind !== SyntaxKind.OmittedExpression) {
|
||||
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
|
||||
let paramType = getTypeAtPosition(signature, i);
|
||||
let argType: Type;
|
||||
if (i === 0 && args[i].parent.kind === SyntaxKind.TaggedTemplateExpression) {
|
||||
argType = globalTemplateStringsArrayType;
|
||||
@@ -6638,7 +6671,7 @@ module ts {
|
||||
// No need to check for omitted args and template expressions, their exlusion value is always undefined
|
||||
if (excludeArgument[i] === false) {
|
||||
let arg = args[i];
|
||||
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
|
||||
let paramType = getTypeAtPosition(signature, i);
|
||||
inferTypes(context, checkExpressionWithContextualType(arg, paramType, inferenceMapper), paramType);
|
||||
}
|
||||
}
|
||||
@@ -6671,7 +6704,7 @@ module ts {
|
||||
let arg = args[i];
|
||||
if (arg.kind !== SyntaxKind.OmittedExpression) {
|
||||
// Check spread elements against rest type (from arity check we know spread argument corresponds to a rest parameter)
|
||||
let paramType = getTypeAtPosition(signature, arg.kind === SyntaxKind.SpreadElementExpression ? -1 : i);
|
||||
let paramType = getTypeAtPosition(signature, i);
|
||||
// A tagged template expression provides a special first argument, and string literals get string literal types
|
||||
// unless we're reporting errors
|
||||
let argType = i === 0 && node.kind === SyntaxKind.TaggedTemplateExpression ? globalTemplateStringsArrayType :
|
||||
@@ -7145,14 +7178,9 @@ module ts {
|
||||
}
|
||||
|
||||
function getTypeAtPosition(signature: Signature, pos: number): Type {
|
||||
if (pos >= 0) {
|
||||
return signature.hasRestParameter ?
|
||||
pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) :
|
||||
pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType;
|
||||
}
|
||||
return signature.hasRestParameter ?
|
||||
getTypeOfSymbol(signature.parameters[signature.parameters.length - 1]) :
|
||||
anyArrayType;
|
||||
pos < signature.parameters.length - 1 ? getTypeOfSymbol(signature.parameters[pos]) : getRestTypeOfSignature(signature) :
|
||||
pos < signature.parameters.length ? getTypeOfSymbol(signature.parameters[pos]) : anyType;
|
||||
}
|
||||
|
||||
function assignContextualParameterTypes(signature: Signature, context: Signature, mapper: TypeMapper) {
|
||||
@@ -7588,11 +7616,10 @@ module ts {
|
||||
}
|
||||
|
||||
function checkArrayLiteralAssignment(node: ArrayLiteralExpression, sourceType: Type, contextualMapper?: TypeMapper): Type {
|
||||
// TODOO(andersh): Allow iterable source type in ES6
|
||||
if (!isArrayLikeType(sourceType)) {
|
||||
error(node, Diagnostics.Type_0_is_not_an_array_type, typeToString(sourceType));
|
||||
return sourceType;
|
||||
}
|
||||
// This elementType will be used if the specific property corresponding to this index is not
|
||||
// present (aka the tuple element property). This call also checks that the parentType is in
|
||||
// fact an iterable or array (depending on target language).
|
||||
let elementType = checkIteratedTypeOrElementType(sourceType, node, /*allowStringInput*/ false);
|
||||
let elements = node.elements;
|
||||
for (let i = 0; i < elements.length; i++) {
|
||||
let e = elements[i];
|
||||
@@ -7600,8 +7627,9 @@ module ts {
|
||||
if (e.kind !== SyntaxKind.SpreadElementExpression) {
|
||||
let propName = "" + i;
|
||||
let type = sourceType.flags & TypeFlags.Any ? sourceType :
|
||||
isTupleLikeType(sourceType) ? getTypeOfPropertyOfType(sourceType, propName) :
|
||||
getIndexTypeOfType(sourceType, IndexKind.Number);
|
||||
isTupleLikeType(sourceType)
|
||||
? getTypeOfPropertyOfType(sourceType, propName)
|
||||
: elementType;
|
||||
if (type) {
|
||||
checkDestructuringAssignment(e, type, contextualMapper);
|
||||
}
|
||||
@@ -7616,7 +7644,7 @@ module ts {
|
||||
}
|
||||
else {
|
||||
if (i === elements.length - 1) {
|
||||
checkReferenceAssignment((<SpreadElementExpression>e).expression, sourceType, contextualMapper);
|
||||
checkReferenceAssignment((<SpreadElementExpression>e).expression, createArrayType(elementType), contextualMapper);
|
||||
}
|
||||
else {
|
||||
error(e, Diagnostics.A_rest_element_must_be_last_in_an_array_destructuring_pattern);
|
||||
@@ -9373,29 +9401,41 @@ module ts {
|
||||
|
||||
function checkRightHandSideOfForOf(rhsExpression: Expression): Type {
|
||||
let expressionType = getTypeOfExpression(rhsExpression);
|
||||
return languageVersion >= ScriptTarget.ES6
|
||||
? checkIteratedType(expressionType, rhsExpression)
|
||||
: checkElementTypeOfArrayOrString(expressionType, rhsExpression);
|
||||
return checkIteratedTypeOrElementType(expressionType, rhsExpression, /*allowStringInput*/ true);
|
||||
}
|
||||
|
||||
function checkIteratedTypeOrElementType(inputType: Type, errorNode: Node, allowStringInput: boolean): Type {
|
||||
if (languageVersion >= ScriptTarget.ES6) {
|
||||
return checkIteratedType(inputType, errorNode) || anyType;
|
||||
}
|
||||
|
||||
if (allowStringInput) {
|
||||
return checkElementTypeOfArrayOrString(inputType, errorNode);
|
||||
}
|
||||
|
||||
if (isArrayLikeType(inputType)) {
|
||||
return getIndexTypeOfType(inputType, IndexKind.Number);
|
||||
}
|
||||
|
||||
error(errorNode, Diagnostics.Type_0_is_not_an_array_type, typeToString(inputType));
|
||||
return unknownType;
|
||||
}
|
||||
|
||||
/**
|
||||
* When expressionForError is undefined, it means we should not report any errors.
|
||||
* When errorNode is undefined, it means we should not report any errors.
|
||||
*/
|
||||
function checkIteratedType(iterable: Type, expressionForError: Expression): Type {
|
||||
function checkIteratedType(iterable: Type, errorNode: Node): Type {
|
||||
Debug.assert(languageVersion >= ScriptTarget.ES6);
|
||||
let iteratedType = getIteratedType(iterable, expressionForError);
|
||||
let iteratedType = getIteratedType(iterable, errorNode);
|
||||
// Now even though we have extracted the iteratedType, we will have to validate that the type
|
||||
// passed in is actually an Iterable.
|
||||
if (expressionForError && iteratedType) {
|
||||
let completeIterableType = globalIterableType !== emptyObjectType
|
||||
? createTypeReference(<GenericType>globalIterableType, [iteratedType])
|
||||
: emptyObjectType;
|
||||
checkTypeAssignableTo(iterable, completeIterableType, expressionForError);
|
||||
if (errorNode && iteratedType) {
|
||||
checkTypeAssignableTo(iterable, createIterableType(iteratedType), errorNode);
|
||||
}
|
||||
|
||||
return iteratedType;
|
||||
|
||||
function getIteratedType(iterable: Type, expressionForError: Expression) {
|
||||
function getIteratedType(iterable: Type, errorNode: Node) {
|
||||
// We want to treat type as an iterable, and get the type it is an iterable of. The iterable
|
||||
// must have the following structure (annotated with the names of the variables below):
|
||||
//
|
||||
@@ -9426,6 +9466,12 @@ module ts {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// As an optimization, if the type is instantiated directly using the globalIterableType (Iterable<number>),
|
||||
// then just grab its type argument.
|
||||
if ((iterable.flags & TypeFlags.Reference) && (<GenericType>iterable).target === globalIterableType) {
|
||||
return (<GenericType>iterable).typeArguments[0];
|
||||
}
|
||||
|
||||
let iteratorFunction = getTypeOfPropertyOfType(iterable, getPropertyNameForKnownSymbolName("iterator"));
|
||||
if (iteratorFunction && allConstituentTypesHaveKind(iteratorFunction, TypeFlags.Any)) {
|
||||
return undefined;
|
||||
@@ -9433,8 +9479,8 @@ module ts {
|
||||
|
||||
let iteratorFunctionSignatures = iteratorFunction ? getSignaturesOfType(iteratorFunction, SignatureKind.Call) : emptyArray;
|
||||
if (iteratorFunctionSignatures.length === 0) {
|
||||
if (expressionForError) {
|
||||
error(expressionForError, Diagnostics.The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
|
||||
if (errorNode) {
|
||||
error(errorNode, Diagnostics.Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -9451,8 +9497,8 @@ module ts {
|
||||
|
||||
let iteratorNextFunctionSignatures = iteratorNextFunction ? getSignaturesOfType(iteratorNextFunction, SignatureKind.Call) : emptyArray;
|
||||
if (iteratorNextFunctionSignatures.length === 0) {
|
||||
if (expressionForError) {
|
||||
error(expressionForError, Diagnostics.The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method);
|
||||
if (errorNode) {
|
||||
error(errorNode, Diagnostics.An_iterator_must_have_a_next_method);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -9464,8 +9510,8 @@ module ts {
|
||||
|
||||
let iteratorNextValue = getTypeOfPropertyOfType(iteratorNextResult, "value");
|
||||
if (!iteratorNextValue) {
|
||||
if (expressionForError) {
|
||||
error(expressionForError, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property);
|
||||
if (errorNode) {
|
||||
error(errorNode, Diagnostics.The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
@@ -9491,7 +9537,7 @@ module ts {
|
||||
* 1. Some constituent is neither a string nor an array.
|
||||
* 2. Some constituent is a string and target is less than ES5 (because in ES3 string is not indexable).
|
||||
*/
|
||||
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, expressionForError: Expression): Type {
|
||||
function checkElementTypeOfArrayOrString(arrayOrStringType: Type, errorNode: Node): Type {
|
||||
Debug.assert(languageVersion < ScriptTarget.ES6);
|
||||
|
||||
// After we remove all types that are StringLike, we will know if there was a string constituent
|
||||
@@ -9502,7 +9548,7 @@ module ts {
|
||||
let reportedError = false;
|
||||
if (hasStringConstituent) {
|
||||
if (languageVersion < ScriptTarget.ES5) {
|
||||
error(expressionForError, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
|
||||
error(errorNode, Diagnostics.Using_a_string_in_a_for_of_statement_is_only_supported_in_ECMAScript_5_and_higher);
|
||||
reportedError = true;
|
||||
}
|
||||
|
||||
@@ -9522,7 +9568,7 @@ module ts {
|
||||
let diagnostic = hasStringConstituent
|
||||
? Diagnostics.Type_0_is_not_an_array_type
|
||||
: Diagnostics.Type_0_is_not_an_array_type_or_a_string_type;
|
||||
error(expressionForError, diagnostic, typeToString(arrayType));
|
||||
error(errorNode, diagnostic, typeToString(arrayType));
|
||||
}
|
||||
return hasStringConstituent ? stringType : unknownType;
|
||||
}
|
||||
|
||||
@@ -434,7 +434,7 @@ module ts {
|
||||
return path.replace(/\\/g, "/");
|
||||
}
|
||||
|
||||
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/")
|
||||
// Returns length of path root (i.e. length of "/", "x:/", "//server/share/, file:///user/files")
|
||||
export function getRootLength(path: string): number {
|
||||
if (path.charCodeAt(0) === CharacterCodes.slash) {
|
||||
if (path.charCodeAt(1) !== CharacterCodes.slash) return 1;
|
||||
@@ -448,6 +448,8 @@ module ts {
|
||||
if (path.charCodeAt(2) === CharacterCodes.slash) return 3;
|
||||
return 2;
|
||||
}
|
||||
let idx = path.indexOf('://');
|
||||
if (idx !== -1) return idx + 3
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -344,8 +344,8 @@ module ts {
|
||||
The_left_hand_side_of_a_for_of_statement_cannot_be_a_previously_defined_constant: { code: 2485, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...of' statement cannot be a previously defined constant." },
|
||||
The_left_hand_side_of_a_for_in_statement_cannot_be_a_previously_defined_constant: { code: 2486, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a previously defined constant." },
|
||||
Invalid_left_hand_side_in_for_of_statement: { code: 2487, category: DiagnosticCategory.Error, key: "Invalid left-hand side in 'for...of' statement." },
|
||||
The_right_hand_side_of_a_for_of_statement_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator." },
|
||||
The_iterator_returned_by_the_right_hand_side_of_a_for_of_statement_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method." },
|
||||
Type_must_have_a_Symbol_iterator_method_that_returns_an_iterator: { code: 2488, category: DiagnosticCategory.Error, key: "Type must have a '[Symbol.iterator]()' method that returns an iterator." },
|
||||
An_iterator_must_have_a_next_method: { code: 2489, category: DiagnosticCategory.Error, key: "An iterator must have a 'next()' method." },
|
||||
The_type_returned_by_the_next_method_of_an_iterator_must_have_a_value_property: { code: 2490, category: DiagnosticCategory.Error, key: "The type returned by the 'next()' method of an iterator must have a 'value' property." },
|
||||
The_left_hand_side_of_a_for_in_statement_cannot_be_a_destructuring_pattern: { code: 2491, category: DiagnosticCategory.Error, key: "The left-hand side of a 'for...in' statement cannot be a destructuring pattern." },
|
||||
Cannot_redeclare_identifier_0_in_catch_clause: { code: 2492, category: DiagnosticCategory.Error, key: "Cannot redeclare identifier '{0}' in catch clause" },
|
||||
|
||||
@@ -1367,11 +1367,11 @@
|
||||
"category": "Error",
|
||||
"code": 2487
|
||||
},
|
||||
"The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.": {
|
||||
"Type must have a '[Symbol.iterator]()' method that returns an iterator.": {
|
||||
"category": "Error",
|
||||
"code": 2488
|
||||
},
|
||||
"The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.": {
|
||||
"An iterator must have a 'next()' method.": {
|
||||
"category": "Error",
|
||||
"code": 2489
|
||||
},
|
||||
|
||||
+164
-192
@@ -1157,8 +1157,8 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
if (!computedPropertyNamesToGeneratedNames) {
|
||||
computedPropertyNamesToGeneratedNames = [];
|
||||
}
|
||||
|
||||
let generatedName = computedPropertyNamesToGeneratedNames[node.id];
|
||||
|
||||
let generatedName = computedPropertyNamesToGeneratedNames[getNodeId(node)];
|
||||
if (generatedName) {
|
||||
// we have already generated a variable for this node, write that value instead.
|
||||
write(generatedName);
|
||||
@@ -1166,7 +1166,7 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
}
|
||||
|
||||
generatedName = createAndRecordTempVariable(TempFlags.Auto).text;
|
||||
computedPropertyNamesToGeneratedNames[node.id] = generatedName;
|
||||
computedPropertyNamesToGeneratedNames[getNodeId(node)] = generatedName;
|
||||
write(generatedName);
|
||||
write(" = ");
|
||||
}
|
||||
@@ -1402,211 +1402,163 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
}
|
||||
}
|
||||
|
||||
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number): void {
|
||||
let parenthesizedObjectLiteral = createDownlevelObjectLiteralWithComputedProperties(node, firstComputedPropertyIndex);
|
||||
return emit(parenthesizedObjectLiteral);
|
||||
function emitObjectLiteralBody(node: ObjectLiteralExpression, numElements: number): void {
|
||||
if (numElements === 0) {
|
||||
write("{}");
|
||||
return;
|
||||
}
|
||||
|
||||
write("{");
|
||||
|
||||
if (numElements > 0) {
|
||||
var properties = node.properties;
|
||||
|
||||
// If we are not doing a downlevel transformation for object literals,
|
||||
// then try to preserve the original shape of the object literal.
|
||||
// Otherwise just try to preserve the formatting.
|
||||
if (numElements === properties.length) {
|
||||
emitLinePreservingList(node, properties, /* allowTrailingComma */ languageVersion >= ScriptTarget.ES5, /* spacesBetweenBraces */ true);
|
||||
}
|
||||
else {
|
||||
let multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
|
||||
if (!multiLine) {
|
||||
write(" ");
|
||||
}
|
||||
else {
|
||||
increaseIndent();
|
||||
}
|
||||
|
||||
emitList(properties, 0, numElements, /*multiLine*/ multiLine, /*trailingComma*/ false);
|
||||
|
||||
if (!multiLine) {
|
||||
write(" ");
|
||||
}
|
||||
else {
|
||||
decreaseIndent();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
write("}");
|
||||
}
|
||||
|
||||
function createDownlevelObjectLiteralWithComputedProperties(originalObjectLiteral: ObjectLiteralExpression, firstComputedPropertyIndex: number): ParenthesizedExpression {
|
||||
function emitDownlevelObjectLiteralWithComputedProperties(node: ObjectLiteralExpression, firstComputedPropertyIndex: number) {
|
||||
let multiLine = (node.flags & NodeFlags.MultiLine) !== 0;
|
||||
let properties = node.properties;
|
||||
|
||||
write("(");
|
||||
|
||||
if (multiLine) {
|
||||
increaseIndent();
|
||||
}
|
||||
|
||||
// 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.
|
||||
let tempVar = createAndRecordTempVariable(TempFlags.Auto);
|
||||
|
||||
// Hold onto the initial non-computed properties in a new object literal,
|
||||
// then create the rest through property accesses on the temp variable.
|
||||
let initialObjectLiteral = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
|
||||
initialObjectLiteral.properties = <NodeArray<ObjectLiteralElement>>originalObjectLiteral.properties.slice(0, firstComputedPropertyIndex);
|
||||
initialObjectLiteral.flags |= NodeFlags.MultiLine;
|
||||
// Write out the first non-computed properties
|
||||
// (or all properties if none of them are computed),
|
||||
// then emit the rest through indexing on the temp variable.
|
||||
emit(tempVar)
|
||||
write(" = ");
|
||||
emitObjectLiteralBody(node, firstComputedPropertyIndex);
|
||||
|
||||
// The comma expressions that will patch the object literal.
|
||||
// This will end up being something like '_a = { ... }, _a.x = 10, _a.y = 20, _a'.
|
||||
let propertyPatches = createBinaryExpression(tempVar, SyntaxKind.EqualsToken, initialObjectLiteral);
|
||||
for (let i = firstComputedPropertyIndex, n = properties.length; i < n; i++) {
|
||||
writeComma();
|
||||
|
||||
ts.forEach(originalObjectLiteral.properties, property => {
|
||||
let patchedProperty = tryCreatePatchingPropertyAssignment(originalObjectLiteral, tempVar, property);
|
||||
if (patchedProperty) {
|
||||
// TODO(drosen): Preserve comments
|
||||
//let leadingComments = getLeadingCommentRanges(currentSourceFile.text, property.pos);
|
||||
//let trailingComments = getTrailingCommentRanges(currentSourceFile.text, property.end);
|
||||
//addCommentsToSynthesizedNode(patchedProperty, leadingComments, trailingComments);
|
||||
let property = properties[i];
|
||||
|
||||
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, patchedProperty);
|
||||
emitStart(property)
|
||||
if (property.kind === SyntaxKind.GetAccessor || property.kind === SyntaxKind.SetAccessor) {
|
||||
// TODO (drosen): Reconcile with 'emitMemberFunctions'.
|
||||
let accessors = getAllAccessorDeclarations(node.properties, <AccessorDeclaration>property);
|
||||
if (property !== accessors.firstAccessor) {
|
||||
continue;
|
||||
}
|
||||
write("Object.defineProperty(");
|
||||
emit(tempVar);
|
||||
write(", ");
|
||||
emitStart(node.name);
|
||||
emitExpressionForPropertyName(property.name);
|
||||
emitEnd(property.name);
|
||||
write(", {");
|
||||
increaseIndent();
|
||||
if (accessors.getAccessor) {
|
||||
writeLine()
|
||||
emitLeadingComments(accessors.getAccessor);
|
||||
write("get: ");
|
||||
emitStart(accessors.getAccessor);
|
||||
write("function ");
|
||||
emitSignatureAndBody(accessors.getAccessor);
|
||||
emitEnd(accessors.getAccessor);
|
||||
emitTrailingComments(accessors.getAccessor);
|
||||
write(",");
|
||||
}
|
||||
if (accessors.setAccessor) {
|
||||
writeLine();
|
||||
emitLeadingComments(accessors.setAccessor);
|
||||
write("set: ");
|
||||
emitStart(accessors.setAccessor);
|
||||
write("function ");
|
||||
emitSignatureAndBody(accessors.setAccessor);
|
||||
emitEnd(accessors.setAccessor);
|
||||
emitTrailingComments(accessors.setAccessor);
|
||||
write(",");
|
||||
}
|
||||
writeLine();
|
||||
write("enumerable: true,");
|
||||
writeLine();
|
||||
write("configurable: true");
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
write("})");
|
||||
emitEnd(property);
|
||||
}
|
||||
});
|
||||
else {
|
||||
emitLeadingComments(property);
|
||||
emitStart(property.name);
|
||||
emit(tempVar);
|
||||
emitMemberAccessForPropertyName(property.name);
|
||||
emitEnd(property.name);
|
||||
|
||||
// Finally, return the temp variable.
|
||||
propertyPatches = createBinaryExpression(propertyPatches, SyntaxKind.CommaToken, createIdentifier(tempVar.text, /*startsOnNewLine:*/ true));
|
||||
write(" = ");
|
||||
|
||||
let result = createParenthesizedExpression(propertyPatches);
|
||||
|
||||
// TODO(drosen): Preserve comments
|
||||
// let leadingComments = getLeadingCommentRanges(currentSourceFile.text, originalObjectLiteral.pos);
|
||||
// let 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 {
|
||||
let leftHandSide = createMemberAccessForPropertyName(tempVar, property.name);
|
||||
let maybeRightHandSide = tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral, property);
|
||||
|
||||
return maybeRightHandSide && createBinaryExpression(leftHandSide, SyntaxKind.EqualsToken, maybeRightHandSide, /*startsOnNewLine:*/ true);
|
||||
}
|
||||
|
||||
function tryGetRightHandSideOfPatchingPropertyAssignment(objectLiteral: ObjectLiteralExpression, property: ObjectLiteralElement) {
|
||||
switch (property.kind) {
|
||||
case SyntaxKind.PropertyAssignment:
|
||||
return (<PropertyAssignment>property).initializer;
|
||||
|
||||
case SyntaxKind.ShorthandPropertyAssignment:
|
||||
// TODO: (andersh) Technically it isn't correct to make an identifier here since getExpressionNamePrefix returns
|
||||
// a string containing a dotted name. In general I'm not a fan of mini tree rewriters as this one, elsewhere we
|
||||
// manage by just emitting strings (which is a lot more performant).
|
||||
//let prefix = createIdentifier(resolver.getExpressionNamePrefix((<ShorthandPropertyAssignment>property).name));
|
||||
//return createPropertyAccessExpression(prefix, (<ShorthandPropertyAssignment>property).name);
|
||||
return createIdentifier(resolver.getExpressionNameSubstitution((<ShorthandPropertyAssignment>property).name, getGeneratedNameForNode));
|
||||
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
return createFunctionExpression((<MethodDeclaration>property).parameters, (<MethodDeclaration>property).body);
|
||||
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
let { firstAccessor, getAccessor, setAccessor } = getAllAccessorDeclarations(objectLiteral.properties, <AccessorDeclaration>property);
|
||||
|
||||
// Only emit the first accessor.
|
||||
if (firstAccessor !== property) {
|
||||
return undefined;
|
||||
if (property.kind === SyntaxKind.PropertyAssignment) {
|
||||
emit((<PropertyAssignment>property).initializer);
|
||||
}
|
||||
|
||||
let propertyDescriptor = <ObjectLiteralExpression>createSynthesizedNode(SyntaxKind.ObjectLiteralExpression);
|
||||
|
||||
let descriptorProperties = <NodeArray<ObjectLiteralElement>>[];
|
||||
if (getAccessor) {
|
||||
let getProperty = createPropertyAssignment(createIdentifier("get"), createFunctionExpression(getAccessor.parameters, getAccessor.body));
|
||||
descriptorProperties.push(getProperty);
|
||||
else if (property.kind === SyntaxKind.ShorthandPropertyAssignment) {
|
||||
emitExpressionIdentifier((<ShorthandPropertyAssignment>property).name);
|
||||
}
|
||||
if (setAccessor) {
|
||||
let setProperty = createPropertyAssignment(createIdentifier("set"), createFunctionExpression(setAccessor.parameters, setAccessor.body));
|
||||
descriptorProperties.push(setProperty);
|
||||
else if (property.kind === SyntaxKind.MethodDeclaration) {
|
||||
emitFunctionDeclaration(<MethodDeclaration>property);
|
||||
}
|
||||
else {
|
||||
Debug.fail("ObjectLiteralElement type not accounted for: " + property.kind);
|
||||
}
|
||||
}
|
||||
|
||||
let trueExpr = <PrimaryExpression>createSynthesizedNode(SyntaxKind.TrueKeyword);
|
||||
|
||||
let enumerableTrue = createPropertyAssignment(createIdentifier("enumerable"), trueExpr);
|
||||
descriptorProperties.push(enumerableTrue);
|
||||
|
||||
let configurableTrue = createPropertyAssignment(createIdentifier("configurable"), trueExpr);
|
||||
descriptorProperties.push(configurableTrue);
|
||||
|
||||
propertyDescriptor.properties = descriptorProperties;
|
||||
|
||||
let objectDotDefineProperty = createPropertyAccessExpression(createIdentifier("Object"), createIdentifier("defineProperty"));
|
||||
return createCallExpression(objectDotDefineProperty, createNodeArray(propertyDescriptor));
|
||||
|
||||
default:
|
||||
Debug.fail(`ObjectLiteralElement kind ${property.kind} not accounted for.`);
|
||||
emitEnd(property);
|
||||
}
|
||||
}
|
||||
|
||||
function createParenthesizedExpression(expression: Expression) {
|
||||
let result = <ParenthesizedExpression>createSynthesizedNode(SyntaxKind.ParenthesizedExpression);
|
||||
result.expression = expression;
|
||||
writeComma();
|
||||
emit(tempVar);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createNodeArray<T extends Node>(...elements: T[]): NodeArray<T> {
|
||||
let result = <NodeArray<T>>elements;
|
||||
result.pos = -1;
|
||||
result.end = -1;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression {
|
||||
let result = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine);
|
||||
result.operatorToken = createSynthesizedNode(operator);
|
||||
result.left = left;
|
||||
result.right = right;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createExpressionStatement(expression: Expression): ExpressionStatement {
|
||||
let result = <ExpressionStatement>createSynthesizedNode(SyntaxKind.ExpressionStatement);
|
||||
result.expression = expression;
|
||||
return result;
|
||||
}
|
||||
|
||||
function createMemberAccessForPropertyName(expression: LeftHandSideExpression, memberName: DeclarationName): PropertyAccessExpression | ElementAccessExpression {
|
||||
if (memberName.kind === SyntaxKind.Identifier) {
|
||||
return createPropertyAccessExpression(expression, <Identifier>memberName);
|
||||
if (multiLine) {
|
||||
decreaseIndent();
|
||||
writeLine();
|
||||
}
|
||||
else if (memberName.kind === SyntaxKind.StringLiteral || memberName.kind === SyntaxKind.NumericLiteral) {
|
||||
return createElementAccessExpression(expression, <LiteralExpression>memberName);
|
||||
|
||||
write(")");
|
||||
|
||||
function writeComma() {
|
||||
if (multiLine) {
|
||||
write(",");
|
||||
writeLine();
|
||||
}
|
||||
else {
|
||||
write(", ");
|
||||
}
|
||||
}
|
||||
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) {
|
||||
let result = <PropertyAssignment>createSynthesizedNode(SyntaxKind.PropertyAssignment);
|
||||
result.name = name;
|
||||
result.initializer = initializer;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createFunctionExpression(parameters: NodeArray<ParameterDeclaration>, body: Block): FunctionExpression {
|
||||
let result = <FunctionExpression>createSynthesizedNode(SyntaxKind.FunctionExpression);
|
||||
result.parameters = parameters;
|
||||
result.body = body;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
|
||||
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
|
||||
result.expression = expression;
|
||||
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
|
||||
result.name = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
|
||||
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
|
||||
result.expression = expression;
|
||||
result.argumentExpression = argumentExpression;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createIdentifier(name: string, startsOnNewLine?: boolean) {
|
||||
let result = <Identifier>createSynthesizedNode(SyntaxKind.Identifier, startsOnNewLine);
|
||||
result.text = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createCallExpression(invokedExpression: MemberExpression, arguments: NodeArray<Expression>) {
|
||||
let result = <CallExpression>createSynthesizedNode(SyntaxKind.CallExpression);
|
||||
result.expression = invokedExpression;
|
||||
result.arguments = arguments;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function emitObjectLiteral(node: ObjectLiteralExpression): void {
|
||||
@@ -1634,13 +1586,33 @@ var __param = this.__param || function(index, decorator) { return function (targ
|
||||
|
||||
// Ordinary case: either the object has no computed properties
|
||||
// or we're compiling with an ES6+ target.
|
||||
write("{");
|
||||
emitObjectLiteralBody(node, properties.length);
|
||||
}
|
||||
|
||||
if (properties.length) {
|
||||
emitLinePreservingList(node, properties, /*allowTrailingComma:*/ languageVersion >= ScriptTarget.ES5, /*spacesBetweenBraces:*/ true)
|
||||
}
|
||||
function createBinaryExpression(left: Expression, operator: SyntaxKind, right: Expression, startsOnNewLine?: boolean): BinaryExpression {
|
||||
let result = <BinaryExpression>createSynthesizedNode(SyntaxKind.BinaryExpression, startsOnNewLine);
|
||||
result.operatorToken = createSynthesizedNode(operator);
|
||||
result.left = left;
|
||||
result.right = right;
|
||||
|
||||
write("}");
|
||||
return result;
|
||||
}
|
||||
|
||||
function createPropertyAccessExpression(expression: LeftHandSideExpression, name: Identifier): PropertyAccessExpression {
|
||||
let result = <PropertyAccessExpression>createSynthesizedNode(SyntaxKind.PropertyAccessExpression);
|
||||
result.expression = expression;
|
||||
result.dotToken = createSynthesizedNode(SyntaxKind.DotToken);
|
||||
result.name = name;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function createElementAccessExpression(expression: LeftHandSideExpression, argumentExpression: Expression): ElementAccessExpression {
|
||||
let result = <ElementAccessExpression>createSynthesizedNode(SyntaxKind.ElementAccessExpression);
|
||||
result.expression = expression;
|
||||
result.argumentExpression = argumentExpression;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
function emitComputedPropertyName(node: ComputedPropertyName) {
|
||||
|
||||
@@ -526,6 +526,19 @@ module ts {
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
// If the decorator's parent is a Parameter, we resolve the this container from
|
||||
// the grandparent class declaration.
|
||||
node = node.parent.parent;
|
||||
}
|
||||
else if (isClassElement(node.parent)) {
|
||||
// If the decorator's parent is a class element, we resolve the 'this' container
|
||||
// from the parent class declaration.
|
||||
node = node.parent;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.ArrowFunction:
|
||||
if (!includeArrowFunctions) {
|
||||
continue;
|
||||
@@ -568,6 +581,19 @@ module ts {
|
||||
// the *body* of the container.
|
||||
node = node.parent;
|
||||
break;
|
||||
case SyntaxKind.Decorator:
|
||||
// Decorators are always applied outside of the body of a class or method.
|
||||
if (node.parent.kind === SyntaxKind.Parameter && isClassElement(node.parent.parent)) {
|
||||
// If the decorator's parent is a Parameter, we resolve the this container from
|
||||
// the grandparent class declaration.
|
||||
node = node.parent.parent;
|
||||
}
|
||||
else if (isClassElement(node.parent)) {
|
||||
// If the decorator's parent is a class element, we resolve the 'this' container
|
||||
// from the parent class declaration.
|
||||
node = node.parent;
|
||||
}
|
||||
break;
|
||||
case SyntaxKind.FunctionDeclaration:
|
||||
case SyntaxKind.FunctionExpression:
|
||||
case SyntaxKind.ArrowFunction:
|
||||
@@ -754,6 +780,8 @@ module ts {
|
||||
return node === (<TemplateSpan>parent).expression;
|
||||
case SyntaxKind.ComputedPropertyName:
|
||||
return node === (<ComputedPropertyName>parent).expression;
|
||||
case SyntaxKind.Decorator:
|
||||
return true;
|
||||
default:
|
||||
if (isExpression(parent)) {
|
||||
return true;
|
||||
@@ -919,6 +947,7 @@ module ts {
|
||||
case SyntaxKind.MethodDeclaration:
|
||||
case SyntaxKind.GetAccessor:
|
||||
case SyntaxKind.SetAccessor:
|
||||
case SyntaxKind.MethodSignature:
|
||||
case SyntaxKind.IndexSignature:
|
||||
return true;
|
||||
default:
|
||||
|
||||
@@ -336,6 +336,9 @@ module Harness.LanguageService {
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ts.ReferenceEntry[] {
|
||||
return unwrapJSONCallResult(this.shim.getOccurrencesAtPosition(fileName, position));
|
||||
}
|
||||
getDocumentHighlights(fileName: string, position: number, filesToSearch: string[]): ts.DocumentHighlights[] {
|
||||
return unwrapJSONCallResult(this.shim.getDocumentHighlights(fileName, position, JSON.stringify(filesToSearch)));
|
||||
}
|
||||
getNavigateToItems(searchValue: string): ts.NavigateToItem[] {
|
||||
return unwrapJSONCallResult(this.shim.getNavigateToItems(searchValue));
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ class TypeWriterWalker {
|
||||
case ts.SyntaxKind.PostfixUnaryExpression:
|
||||
case ts.SyntaxKind.BinaryExpression:
|
||||
case ts.SyntaxKind.ConditionalExpression:
|
||||
case ts.SyntaxKind.SpreadElementExpression:
|
||||
this.log(node, this.getTypeOfNode(node));
|
||||
break;
|
||||
|
||||
|
||||
+25
-1
@@ -104,7 +104,7 @@ module ts.server {
|
||||
var response: T = JSON.parse(responseBody);
|
||||
}
|
||||
catch (e) {
|
||||
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error detailes: " + e.message);
|
||||
throw new Error("Malformed response: Failed to parse server response: " + lastMessage + ". \r\n Error details: " + e.message);
|
||||
}
|
||||
|
||||
// verify the sequence numbers
|
||||
@@ -446,6 +446,7 @@ module ts.server {
|
||||
if (!response.body) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var helpItems: protocol.SignatureHelpItems = response.body;
|
||||
var span = helpItems.applicableSpan;
|
||||
var start = this.lineOffsetToPosition(fileName, span.start);
|
||||
@@ -465,6 +466,29 @@ module ts.server {
|
||||
}
|
||||
|
||||
getOccurrencesAtPosition(fileName: string, position: number): ReferenceEntry[] {
|
||||
var lineOffset = this.positionToOneBasedLineOffset(fileName, position);
|
||||
var args: protocol.FileLocationRequestArgs = {
|
||||
file: fileName,
|
||||
line: lineOffset.line,
|
||||
offset: lineOffset.offset,
|
||||
};
|
||||
|
||||
var request = this.processRequest<protocol.OccurrencesRequest>(CommandNames.Occurrences, args);
|
||||
var response = this.processResponse<protocol.OccurrencesResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = entry.file;
|
||||
var start = this.lineOffsetToPosition(fileName, entry.start);
|
||||
var end = this.lineOffsetToPosition(fileName, entry.end);
|
||||
return {
|
||||
fileName,
|
||||
textSpan: ts.createTextSpanFromBounds(start, end),
|
||||
isWriteAccess: entry.isWriteAccess,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
getDocumentHighlights(fileName: string, position: number): DocumentHighlights[] {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
|
||||
@@ -458,7 +458,7 @@ module ts.server {
|
||||
var info = this.filenameToScriptInfo[args.file];
|
||||
if (info) {
|
||||
info.setFormatOptions(args.formatOptions);
|
||||
this.log("Host configuration update for file " + args.file);
|
||||
this.log("Host configuration update for file " + args.file, "Info");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -823,7 +823,6 @@ module ts.server {
|
||||
*/
|
||||
|
||||
closeClientFile(filename: string) {
|
||||
// TODO: tsconfig check
|
||||
var info = ts.lookUp(this.filenameToScriptInfo, filename);
|
||||
if (info) {
|
||||
this.closeOpenFile(info);
|
||||
@@ -856,6 +855,9 @@ module ts.server {
|
||||
}
|
||||
|
||||
printProjects() {
|
||||
if (!this.psLogger.isVerbose()) {
|
||||
return;
|
||||
}
|
||||
this.psLogger.startGroup();
|
||||
for (var i = 0, len = this.inferredProjects.length; i < len; i++) {
|
||||
var project = this.inferredProjects[i];
|
||||
|
||||
Vendored
+26
@@ -165,6 +165,25 @@ declare module ts.server.protocol {
|
||||
body?: FileSpan[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get occurrences request; value of command field is
|
||||
* "occurrences". Return response giving spans that are relevant
|
||||
* in the file at a given line and column.
|
||||
*/
|
||||
export interface OccurrencesRequest extends FileLocationRequest {
|
||||
}
|
||||
|
||||
export interface OccurrencesResponseItem extends FileSpan {
|
||||
/**
|
||||
* True if the occurrence is a write location, false otherwise.
|
||||
*/
|
||||
isWriteAccess: boolean;
|
||||
}
|
||||
|
||||
export interface OccurrencesResponse extends Response {
|
||||
body?: OccurrencesResponseItem[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Find references request; value of command field is
|
||||
* "references". Return response giving the file locations that
|
||||
@@ -405,6 +424,13 @@ declare module ts.server.protocol {
|
||||
arguments: OpenRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit request; value of command field is "exit". Ask the server process
|
||||
* to exit.
|
||||
*/
|
||||
export interface ExitRequest extends Request {
|
||||
}
|
||||
|
||||
/**
|
||||
* Close request; value of command field is "close". Notify the
|
||||
* server that the client has closed a previously open file. If
|
||||
|
||||
@@ -177,6 +177,12 @@ module ts.server {
|
||||
super(host, logger);
|
||||
}
|
||||
|
||||
exit() {
|
||||
this.projectService.log("Exiting...","Info");
|
||||
this.projectService.closeLog();
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
listen() {
|
||||
rl.on('line',(input: string) => {
|
||||
var message = input.trim();
|
||||
@@ -184,9 +190,7 @@ module ts.server {
|
||||
});
|
||||
|
||||
rl.on('close',() => {
|
||||
this.projectService.log("Exiting...");
|
||||
this.projectService.closeLog();
|
||||
process.exit(0);
|
||||
this.exit();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
+90
-69
@@ -76,25 +76,27 @@ module ts.server {
|
||||
}
|
||||
|
||||
export module CommandNames {
|
||||
export var Brace = "brace";
|
||||
export var Change = "change";
|
||||
export var Close = "close";
|
||||
export var Completions = "completions";
|
||||
export var CompletionDetails = "completionEntryDetails";
|
||||
export var SignatureHelp = "signatureHelp";
|
||||
export var Configure = "configure";
|
||||
export var Definition = "definition";
|
||||
export var Exit = "exit";
|
||||
export var Format = "format";
|
||||
export var Formatonkey = "formatonkey";
|
||||
export var Geterr = "geterr";
|
||||
export var NavBar = "navbar";
|
||||
export var Navto = "navto";
|
||||
export var Occurrences = "occurrences";
|
||||
export var Open = "open";
|
||||
export var Quickinfo = "quickinfo";
|
||||
export var References = "references";
|
||||
export var Reload = "reload";
|
||||
export var Rename = "rename";
|
||||
export var Saveto = "saveto";
|
||||
export var Brace = "brace";
|
||||
export var SignatureHelp = "signatureHelp";
|
||||
export var Unknown = "unknown";
|
||||
}
|
||||
|
||||
@@ -116,7 +118,7 @@ module ts.server {
|
||||
|
||||
constructor(private host: ServerHost, private logger: Logger) {
|
||||
this.projectService =
|
||||
new ProjectService(host, logger, (eventName,project,fileName) => {
|
||||
new ProjectService(host, logger, (eventName, project, fileName) => {
|
||||
this.handleEvent(eventName, project, fileName);
|
||||
});
|
||||
}
|
||||
@@ -261,7 +263,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
getDefinition(line: number, offset: number, fileName: string): protocol.FileSpan[] {
|
||||
getDefinition({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.FileSpan[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -283,7 +285,37 @@ module ts.server {
|
||||
}));
|
||||
}
|
||||
|
||||
getRenameLocations(line: number, offset: number, fileName: string,findInComments: boolean, findInStrings: boolean): protocol.RenameResponseBody {
|
||||
getOccurrences({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.OccurrencesResponseItem[] {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
let project = this.projectService.getProjectForFile(fileName);
|
||||
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
let { compilerService } = project;
|
||||
let position = compilerService.host.lineOffsetToPosition(fileName, line, offset);
|
||||
|
||||
let occurrences = compilerService.languageService.getOccurrencesAtPosition(fileName, position);
|
||||
|
||||
if (!occurrences) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return occurrences.map(occurrence => {
|
||||
let { fileName, isWriteAccess, textSpan } = occurrence;
|
||||
let start = compilerService.host.positionToLineOffset(fileName, textSpan.start);
|
||||
let end = compilerService.host.positionToLineOffset(fileName, ts.textSpanEnd(textSpan));
|
||||
return {
|
||||
start,
|
||||
end,
|
||||
file: fileName,
|
||||
isWriteAccess
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
getRenameLocations({line, offset, file: fileName, findInComments, findInStrings }: protocol.RenameRequestArgs): protocol.RenameResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -351,7 +383,7 @@ module ts.server {
|
||||
return { info: renameInfo, locs: bakedRenameLocs };
|
||||
}
|
||||
|
||||
getReferences(line: number, offset: number, fileName: string): protocol.ReferencesResponseBody {
|
||||
getReferences({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.ReferencesResponseBody {
|
||||
// TODO: get all projects for this file; report refs for all projects deleting duplicates
|
||||
// can avoid duplicates by eliminating same ref file from subsequent projects
|
||||
var file = ts.normalizePath(fileName);
|
||||
@@ -377,7 +409,7 @@ module ts.server {
|
||||
var nameSpan = nameInfo.textSpan;
|
||||
var nameColStart = compilerService.host.positionToLineOffset(file, nameSpan.start).offset;
|
||||
var nameText = compilerService.host.getScriptSnapshot(file).getText(nameSpan.start, ts.textSpanEnd(nameSpan));
|
||||
var bakedRefs: protocol.ReferencesResponseItem[] = references.map((ref) => {
|
||||
var bakedRefs: protocol.ReferencesResponseItem[] = references.map(ref => {
|
||||
var start = compilerService.host.positionToLineOffset(ref.fileName, ref.textSpan.start);
|
||||
var refLineSpan = compilerService.host.lineToTextSpan(ref.fileName, start.line - 1);
|
||||
var snap = compilerService.host.getScriptSnapshot(ref.fileName);
|
||||
@@ -398,12 +430,12 @@ module ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
openClientFile(fileName: string) {
|
||||
openClientFile({ file: fileName }: protocol.OpenRequestArgs) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
this.projectService.openClientFile(file);
|
||||
}
|
||||
|
||||
getQuickInfo(line: number, offset: number, fileName: string): protocol.QuickInfoResponseBody {
|
||||
getQuickInfo({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.QuickInfoResponseBody {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -429,7 +461,7 @@ module ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
getFormattingEditsForRange(line: number, offset: number, endLine: number, endOffset: number, fileName: string): protocol.CodeEdit[] {
|
||||
getFormattingEditsForRange({line, offset, endLine, endOffset, file: fileName}: protocol.FormatRequestArgs): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -456,7 +488,7 @@ module ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getFormattingEditsAfterKeystroke(line: number, offset: number, key: string, fileName: string): protocol.CodeEdit[] {
|
||||
getFormattingEditsAfterKeystroke({line, offset, key, file: fileName}: protocol.FormatOnKeyRequestArgs): protocol.CodeEdit[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
@@ -529,7 +561,7 @@ module ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getCompletions(line: number, offset: number, prefix: string, fileName: string): protocol.CompletionEntry[] {
|
||||
getCompletions({ line, offset, prefix, file: fileName}: protocol.CompletionsRequestArgs): protocol.CompletionEntry[] {
|
||||
if (!prefix) {
|
||||
prefix = "";
|
||||
}
|
||||
@@ -555,8 +587,7 @@ module ts.server {
|
||||
}, []).sort((a, b) => a.name.localeCompare(b.name));
|
||||
}
|
||||
|
||||
getCompletionEntryDetails(line: number, offset: number,
|
||||
entryNames: string[], fileName: string): protocol.CompletionEntryDetails[] {
|
||||
getCompletionEntryDetails({ line, offset, entryNames, file: fileName}: protocol.CompletionDetailsRequestArgs): protocol.CompletionEntryDetails[] {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -575,20 +606,20 @@ module ts.server {
|
||||
}, []);
|
||||
}
|
||||
|
||||
getSignatureHelpItems(line: number, offset: number, fileName: string): protocol.SignatureHelpItems {
|
||||
getSignatureHelpItems({ line, offset, file: fileName }: protocol.SignatureHelpRequestArgs): protocol.SignatureHelpItems {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
throw Errors.NoProject;
|
||||
}
|
||||
|
||||
|
||||
var compilerService = project.compilerService;
|
||||
var position = compilerService.host.lineOffsetToPosition(file, line, offset);
|
||||
var helpItems = compilerService.languageService.getSignatureHelpItems(file, position);
|
||||
if (!helpItems) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
|
||||
var span = helpItems.applicableSpan;
|
||||
var result: protocol.SignatureHelpItems = {
|
||||
items: helpItems.items,
|
||||
@@ -600,11 +631,11 @@ module ts.server {
|
||||
argumentIndex: helpItems.argumentIndex,
|
||||
argumentCount: helpItems.argumentCount,
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
getDiagnostics(delay: number, fileNames: string[]) {
|
||||
|
||||
getDiagnostics({ delay, files: fileNames }: protocol.GeterrRequestArgs): void {
|
||||
var checkList = fileNames.reduce((accum: PendingErrorCheck[], fileName: string) => {
|
||||
fileName = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(fileName);
|
||||
@@ -615,11 +646,11 @@ module ts.server {
|
||||
}, []);
|
||||
|
||||
if (checkList.length > 0) {
|
||||
this.updateErrorCheck(checkList, this.changeSeq,(n) => n == this.changeSeq, delay)
|
||||
this.updateErrorCheck(checkList, this.changeSeq, (n) => n == this.changeSeq, delay)
|
||||
}
|
||||
}
|
||||
|
||||
change(line: number, offset: number, endLine: number, endOffset: number, insertString: string, fileName: string) {
|
||||
change({ line, offset, endLine, endOffset, insertString, file: fileName }: protocol.ChangeRequestArgs): void {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (project) {
|
||||
@@ -634,7 +665,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
reload(fileName: string, tempFileName: string, reqSeq = 0) {
|
||||
reload({ file: fileName, tmpfile: tempFileName }: protocol.ReloadRequestArgs, reqSeq = 0): void {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var tmpfile = ts.normalizePath(tempFileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
@@ -647,7 +678,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
saveToTmp(fileName: string, tempFileName: string) {
|
||||
saveToTmp({ file: fileName, tmpfile: tempFileName }: protocol.SavetoRequestArgs): void {
|
||||
var file = ts.normalizePath(fileName);
|
||||
var tmpfile = ts.normalizePath(tempFileName);
|
||||
|
||||
@@ -657,7 +688,7 @@ module ts.server {
|
||||
}
|
||||
}
|
||||
|
||||
closeClientFile(fileName: string) {
|
||||
closeClientFile({ file: fileName }: protocol.FileRequestArgs) {
|
||||
var file = ts.normalizePath(fileName);
|
||||
this.projectService.closeClientFile(file);
|
||||
}
|
||||
@@ -681,7 +712,7 @@ module ts.server {
|
||||
}));
|
||||
}
|
||||
|
||||
getNavigationBarItems(fileName: string): protocol.NavigationBarItem[] {
|
||||
getNavigationBarItems({ file: fileName }: protocol.FileRequestArgs): protocol.NavigationBarItem[]{
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -697,7 +728,7 @@ module ts.server {
|
||||
return this.decorateNavigationBarItem(project, fileName, items);
|
||||
}
|
||||
|
||||
getNavigateToItems(searchValue: string, fileName: string, maxResultCount?: number): protocol.NavtoItem[] {
|
||||
getNavigateToItems({ searchValue, file: fileName, maxResultCount }: protocol.NavtoRequestArgs): protocol.NavtoItem[]{
|
||||
var file = ts.normalizePath(fileName);
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
if (!project) {
|
||||
@@ -736,7 +767,7 @@ module ts.server {
|
||||
});
|
||||
}
|
||||
|
||||
getBraceMatching(line: number, offset: number, fileName: string): protocol.TextSpan[] {
|
||||
getBraceMatching({ line, offset, file: fileName }: protocol.FileLocationRequestArgs): protocol.TextSpan[]{
|
||||
var file = ts.normalizePath(fileName);
|
||||
|
||||
var project = this.projectService.getProjectForFile(file);
|
||||
@@ -758,6 +789,9 @@ module ts.server {
|
||||
}));
|
||||
}
|
||||
|
||||
exit() {
|
||||
}
|
||||
|
||||
onMessage(message: string) {
|
||||
if (this.logger.isVerbose()) {
|
||||
this.logger.info("request: " + message);
|
||||
@@ -769,110 +803,97 @@ module ts.server {
|
||||
var errorMessage: string;
|
||||
var responseRequired = true;
|
||||
switch (request.command) {
|
||||
case CommandNames.Exit: {
|
||||
this.exit();
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Definition: {
|
||||
var defArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getDefinition(defArgs.line, defArgs.offset, defArgs.file);
|
||||
response = this.getDefinition(<protocol.FileLocationRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.References: {
|
||||
var refArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getReferences(refArgs.line, refArgs.offset, refArgs.file);
|
||||
response = this.getReferences(<protocol.FileLocationRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Rename: {
|
||||
var renameArgs = <protocol.RenameRequestArgs>request.arguments;
|
||||
response = this.getRenameLocations(renameArgs.line, renameArgs.offset, renameArgs.file, renameArgs.findInComments, renameArgs.findInStrings);
|
||||
response = this.getRenameLocations(<protocol.RenameRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Open: {
|
||||
var openArgs = <protocol.OpenRequestArgs>request.arguments;
|
||||
this.openClientFile(openArgs.file);
|
||||
this.openClientFile(<protocol.OpenRequestArgs>request.arguments);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Quickinfo: {
|
||||
var quickinfoArgs = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getQuickInfo(quickinfoArgs.line, quickinfoArgs.offset, quickinfoArgs.file);
|
||||
response = this.getQuickInfo(<protocol.FileLocationRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Format: {
|
||||
var formatArgs = <protocol.FormatRequestArgs>request.arguments;
|
||||
response = this.getFormattingEditsForRange(formatArgs.line, formatArgs.offset, formatArgs.endLine, formatArgs.endOffset, formatArgs.file);
|
||||
response = this.getFormattingEditsForRange(<protocol.FormatRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Formatonkey: {
|
||||
var formatOnKeyArgs = <protocol.FormatOnKeyRequestArgs>request.arguments;
|
||||
response = this.getFormattingEditsAfterKeystroke(formatOnKeyArgs.line, formatOnKeyArgs.offset, formatOnKeyArgs.key, formatOnKeyArgs.file);
|
||||
response = this.getFormattingEditsAfterKeystroke(<protocol.FormatOnKeyRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Completions: {
|
||||
var completionsArgs = <protocol.CompletionsRequestArgs>request.arguments;
|
||||
response = this.getCompletions(completionsArgs.line, completionsArgs.offset, completionsArgs.prefix, completionsArgs.file);
|
||||
response = this.getCompletions(<protocol.CompletionsRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.CompletionDetails: {
|
||||
var completionDetailsArgs = <protocol.CompletionDetailsRequestArgs>request.arguments;
|
||||
response =
|
||||
this.getCompletionEntryDetails(completionDetailsArgs.line,completionDetailsArgs.offset,
|
||||
completionDetailsArgs.entryNames,completionDetailsArgs.file);
|
||||
response = this.getCompletionEntryDetails(<protocol.CompletionDetailsRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.SignatureHelp: {
|
||||
var signatureHelpArgs = <protocol.SignatureHelpRequestArgs>request.arguments;
|
||||
response = this.getSignatureHelpItems(signatureHelpArgs.line, signatureHelpArgs.offset, signatureHelpArgs.file);
|
||||
response = this.getSignatureHelpItems(<protocol.SignatureHelpRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Geterr: {
|
||||
var geterrArgs = <protocol.GeterrRequestArgs>request.arguments;
|
||||
response = this.getDiagnostics(geterrArgs.delay, geterrArgs.files);
|
||||
this.getDiagnostics(<protocol.GeterrRequestArgs>request.arguments);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Change: {
|
||||
var changeArgs = <protocol.ChangeRequestArgs>request.arguments;
|
||||
this.change(changeArgs.line, changeArgs.offset, changeArgs.endLine, changeArgs.endOffset,
|
||||
changeArgs.insertString, changeArgs.file);
|
||||
this.change(<protocol.ChangeRequestArgs>request.arguments);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Configure: {
|
||||
var configureArgs = <protocol.ConfigureRequestArguments>request.arguments;
|
||||
this.projectService.setHostConfiguration(configureArgs);
|
||||
this.projectService.setHostConfiguration(<protocol.ConfigureRequestArguments>request.arguments);
|
||||
this.output(undefined, CommandNames.Configure, request.seq);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Reload: {
|
||||
var reloadArgs = <protocol.ReloadRequestArgs>request.arguments;
|
||||
this.reload(reloadArgs.file, reloadArgs.tmpfile, request.seq);
|
||||
this.reload(<protocol.ReloadRequestArgs>request.arguments);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Saveto: {
|
||||
var savetoArgs = <protocol.SavetoRequestArgs>request.arguments;
|
||||
this.saveToTmp(savetoArgs.file, savetoArgs.tmpfile);
|
||||
this.saveToTmp(<protocol.SavetoRequestArgs>request.arguments);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Close: {
|
||||
var closeArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
this.closeClientFile(closeArgs.file);
|
||||
this.closeClientFile(<protocol.FileRequestArgs>request.arguments);
|
||||
responseRequired = false;
|
||||
break;
|
||||
}
|
||||
case CommandNames.Navto: {
|
||||
var navtoArgs = <protocol.NavtoRequestArgs>request.arguments;
|
||||
response = this.getNavigateToItems(navtoArgs.searchValue, navtoArgs.file, navtoArgs.maxResultCount);
|
||||
response = this.getNavigateToItems(<protocol.NavtoRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Brace: {
|
||||
var braceArguments = <protocol.FileLocationRequestArgs>request.arguments;
|
||||
response = this.getBraceMatching(braceArguments.line, braceArguments.offset, braceArguments.file);
|
||||
response = this.getBraceMatching(<protocol.FileLocationRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.NavBar: {
|
||||
var navBarArgs = <protocol.FileRequestArgs>request.arguments;
|
||||
response = this.getNavigationBarItems(navBarArgs.file);
|
||||
response = this.getNavigationBarItems(<protocol.FileRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
case CommandNames.Occurrences: {
|
||||
response = this.getOccurrences(<protocol.FileLocationRequestArgs>request.arguments);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
|
||||
+672
-566
File diff suppressed because it is too large
Load Diff
@@ -135,11 +135,21 @@ module ts {
|
||||
findReferences(fileName: string, position: number): string;
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; textSpan: { start: number; length: number}; isWriteAccess: boolean }[]
|
||||
*/
|
||||
getOccurrencesAtPosition(fileName: string, position: number): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { fileName: string; highlights: { start: number; length: number, isDefinition: boolean }[] }[]
|
||||
*
|
||||
* @param fileToSearch A JSON encoded string[] containing the file names that should be
|
||||
* considered when searching.
|
||||
*/
|
||||
getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string;
|
||||
|
||||
/**
|
||||
* Returns a JSON-encoded value of the type:
|
||||
* { name: string; kind: string; kindModifiers: string; containerName: string; containerKind: string; matchKind: string; fileName: string; textSpan: { start: number; length: number}; } [] = [];
|
||||
@@ -590,6 +600,14 @@ module ts {
|
||||
});
|
||||
}
|
||||
|
||||
public getDocumentHighlights(fileName: string, position: number, filesToSearch: string): string {
|
||||
return this.forwardJSONCall(
|
||||
"getDocumentHighlights('" + fileName + "', " + position + ")",
|
||||
() => {
|
||||
return this.languageService.getDocumentHighlights(fileName, position, JSON.parse(filesToSearch));
|
||||
});
|
||||
}
|
||||
|
||||
/// COMPLETION LISTS
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,6): error TS2461: Type 'string | number' is not an array type.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,7): error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts(3,14): error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (1 errors) ====
|
||||
==== tests/cases/conformance/statements/for-ofStatements/ES5For-of30.ts (3 errors) ====
|
||||
var a: string, b: number;
|
||||
var tuple: [number, string] = [2, "3"];
|
||||
for ([a = 1, b = ""] of tuple) {
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2461: Type 'string | number' is not an array type.
|
||||
~
|
||||
!!! error TS2322: Type 'number' is not assignable to type 'string'.
|
||||
~
|
||||
!!! error TS2322: Type 'string' is not assignable to type 'number'.
|
||||
a;
|
||||
b;
|
||||
}
|
||||
@@ -14,6 +14,7 @@ obj[Symbol.foo];
|
||||
var Symbol;
|
||||
var obj = (_a = {},
|
||||
_a[Symbol.foo] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
obj[Symbol.foo];
|
||||
var _a;
|
||||
|
||||
@@ -2,7 +2,5 @@
|
||||
var v = { [yield]: foo }
|
||||
|
||||
//// [FunctionDeclaration8_es6.js]
|
||||
var v = (_a = {},
|
||||
_a[yield] = foo,
|
||||
_a);
|
||||
var v = (_a = {}, _a[yield] = foo, _a);
|
||||
var _a;
|
||||
|
||||
@@ -5,8 +5,6 @@ function * foo() {
|
||||
|
||||
//// [FunctionDeclaration9_es6.js]
|
||||
function foo() {
|
||||
var v = (_a = {},
|
||||
_a[] = foo,
|
||||
_a);
|
||||
var v = (_a = {}, _a[] = foo, _a);
|
||||
var _a;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,5 @@
|
||||
var v = { *[foo()]() { } }
|
||||
|
||||
//// [FunctionPropertyAssignments5_es6.js]
|
||||
var v = (_a = {},
|
||||
_a[foo()] = function () { },
|
||||
_a);
|
||||
var v = (_a = {}, _a[foo()] = function () { }, _a);
|
||||
var _a;
|
||||
|
||||
@@ -9,44 +9,55 @@ function f0() {
|
||||
var a1 = [...a];
|
||||
>a1 : number[]
|
||||
>[...a] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var a2 = [1, ...a];
|
||||
>a2 : number[]
|
||||
>[1, ...a] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var a3 = [1, 2, ...a];
|
||||
>a3 : number[]
|
||||
>[1, 2, ...a] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var a4 = [...a, 1];
|
||||
>a4 : number[]
|
||||
>[...a, 1] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var a5 = [...a, 1, 2];
|
||||
>a5 : number[]
|
||||
>[...a, 1, 2] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var a6 = [1, 2, ...a, 1, 2];
|
||||
>a6 : number[]
|
||||
>[1, 2, ...a, 1, 2] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var a7 = [1, ...a, 2, ...a];
|
||||
>a7 : number[]
|
||||
>[1, ...a, 2, ...a] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var a8 = [...a, ...a, ...a];
|
||||
>a8 : number[]
|
||||
>[...a, ...a, ...a] : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
}
|
||||
|
||||
@@ -60,6 +71,7 @@ function f1() {
|
||||
var b = ["hello", ...a, true];
|
||||
>b : (string | number | boolean)[]
|
||||
>["hello", ...a, true] : (string | number | boolean)[]
|
||||
>...a : number
|
||||
>a : number[]
|
||||
|
||||
var b: (string | number | boolean)[];
|
||||
@@ -72,19 +84,29 @@ function f2() {
|
||||
var a = [...[...[...[...[...[]]]]]];
|
||||
>a : any[]
|
||||
>[...[...[...[...[...[]]]]]] : undefined[]
|
||||
>...[...[...[...[...[]]]]] : undefined
|
||||
>[...[...[...[...[]]]]] : undefined[]
|
||||
>...[...[...[...[]]]] : undefined
|
||||
>[...[...[...[]]]] : undefined[]
|
||||
>...[...[...[]]] : undefined
|
||||
>[...[...[]]] : undefined[]
|
||||
>...[...[]] : undefined
|
||||
>[...[]] : undefined[]
|
||||
>...[] : undefined
|
||||
>[] : undefined[]
|
||||
|
||||
var b = [...[...[...[...[...[5]]]]]];
|
||||
>b : number[]
|
||||
>[...[...[...[...[...[5]]]]]] : number[]
|
||||
>...[...[...[...[...[5]]]]] : number
|
||||
>[...[...[...[...[5]]]]] : number[]
|
||||
>...[...[...[...[5]]]] : number
|
||||
>[...[...[...[5]]]] : number[]
|
||||
>...[...[...[5]]] : number
|
||||
>[...[...[5]]] : number[]
|
||||
>...[...[5]] : number
|
||||
>[...[5]] : number[]
|
||||
>...[5] : number
|
||||
>[5] : number[]
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,13 @@ foo(1, 2, "abc");
|
||||
foo(1, 2, ...a);
|
||||
>foo(1, 2, ...a) : void
|
||||
>foo : (x: number, y: number, ...z: string[]) => void
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
foo(1, 2, ...a, "abc");
|
||||
>foo(1, 2, ...a, "abc") : void
|
||||
>foo : (x: number, y: number, ...z: string[]) => void
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
obj.foo(1, 2, "abc");
|
||||
@@ -56,6 +58,7 @@ obj.foo(1, 2, ...a);
|
||||
>obj.foo : (x: number, y: number, ...z: string[]) => any
|
||||
>obj : X
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
obj.foo(1, 2, ...a, "abc");
|
||||
@@ -63,6 +66,7 @@ obj.foo(1, 2, ...a, "abc");
|
||||
>obj.foo : (x: number, y: number, ...z: string[]) => any
|
||||
>obj : X
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
(obj.foo)(1, 2, "abc");
|
||||
@@ -78,6 +82,7 @@ obj.foo(1, 2, ...a, "abc");
|
||||
>obj.foo : (x: number, y: number, ...z: string[]) => any
|
||||
>obj : X
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
(obj.foo)(1, 2, ...a, "abc");
|
||||
@@ -86,6 +91,7 @@ obj.foo(1, 2, ...a, "abc");
|
||||
>obj.foo : (x: number, y: number, ...z: string[]) => any
|
||||
>obj : X
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
xa[1].foo(1, 2, "abc");
|
||||
@@ -101,6 +107,7 @@ xa[1].foo(1, 2, ...a);
|
||||
>xa[1] : X
|
||||
>xa : X[]
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
xa[1].foo(1, 2, ...a, "abc");
|
||||
@@ -109,6 +116,7 @@ xa[1].foo(1, 2, ...a, "abc");
|
||||
>xa[1] : X
|
||||
>xa : X[]
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
(<Function>xa[1].foo)(...[1, 2, "abc"]);
|
||||
@@ -120,6 +128,7 @@ xa[1].foo(1, 2, ...a, "abc");
|
||||
>xa[1] : X
|
||||
>xa : X[]
|
||||
>foo : (x: number, y: number, ...z: string[]) => any
|
||||
>...[1, 2, "abc"] : string | number
|
||||
>[1, 2, "abc"] : (string | number)[]
|
||||
|
||||
class C {
|
||||
@@ -145,6 +154,7 @@ class C {
|
||||
>foo : (x: number, y: number, ...z: string[]) => void
|
||||
>x : number
|
||||
>y : number
|
||||
>...z : string
|
||||
>z : string[]
|
||||
}
|
||||
foo(x: number, y: number, ...z: string[]) {
|
||||
@@ -167,6 +177,7 @@ class D extends C {
|
||||
super(1, 2, ...a);
|
||||
>super(1, 2, ...a) : void
|
||||
>super : typeof C
|
||||
>...a : string
|
||||
>a : string[]
|
||||
}
|
||||
foo() {
|
||||
@@ -183,6 +194,7 @@ class D extends C {
|
||||
>super.foo : (x: number, y: number, ...z: string[]) => void
|
||||
>super : C
|
||||
>foo : (x: number, y: number, ...z: string[]) => void
|
||||
>...a : string
|
||||
>a : string[]
|
||||
}
|
||||
}
|
||||
@@ -192,5 +204,6 @@ var c = new C(1, 2, ...a);
|
||||
>c : C
|
||||
>new C(1, 2, ...a) : C
|
||||
>C : typeof C
|
||||
>...a : string
|
||||
>a : string[]
|
||||
|
||||
|
||||
@@ -32,5 +32,6 @@ var v = (_a = {},
|
||||
_a[true] = function () { },
|
||||
_a["hello bye"] = function () { },
|
||||
_a["hello " + a + " bye"] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -21,16 +21,61 @@ 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);
|
||||
Object.defineProperty(_a, s, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, n, {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, s + s, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, s + n, {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, +s, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, "", {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 0, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, a, {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, true, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, "hello bye", {
|
||||
set: function (v) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, "hello " + a + " bye", {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -9,6 +9,7 @@ function foo() {
|
||||
function foo() {
|
||||
var obj = (_a = {},
|
||||
_a[this.bar] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ var M;
|
||||
(function (M) {
|
||||
var obj = (_a = {},
|
||||
_a[this.bar] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
})(M || (M = {}));
|
||||
|
||||
@@ -6,7 +6,17 @@ var v = {
|
||||
|
||||
//// [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);
|
||||
Object.defineProperty(_a, 0 + 1, {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 0 + 1, {
|
||||
set: function (v) { } //No error
|
||||
,
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -6,5 +6,6 @@ var obj = {
|
||||
//// [computedPropertyNames20_ES5.js]
|
||||
var obj = (_a = {},
|
||||
_a[this.bar] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -15,7 +15,8 @@ var C = (function () {
|
||||
C.prototype.bar = function () {
|
||||
var obj = (_a = {},
|
||||
_a[this.bar()] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -15,9 +15,7 @@ var C = (function () {
|
||||
C.prototype.bar = function () {
|
||||
return 0;
|
||||
};
|
||||
C.prototype[(_a = {},
|
||||
_a[this.bar()] = 1,
|
||||
_a)[0]] = function () { };
|
||||
C.prototype[(_a = {}, _a[this.bar()] = 1, _a)[0]] = function () { };
|
||||
return C;
|
||||
var _a;
|
||||
})();
|
||||
|
||||
@@ -36,7 +36,8 @@ var C = (function (_super) {
|
||||
C.prototype.foo = function () {
|
||||
var obj = (_a = {},
|
||||
_a[_super.prototype.bar.call(this)] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -30,9 +30,7 @@ var C = (function (_super) {
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C.prototype[(_a = {},
|
||||
_a[_super.bar.call(this)] = 1,
|
||||
_a)[0]] = function () { };
|
||||
C.prototype[(_a = {}, _a[_super.bar.call(this)] = 1, _a)[0]] = function () { };
|
||||
return C;
|
||||
var _a;
|
||||
})(Base);
|
||||
|
||||
@@ -28,7 +28,8 @@ var C = (function (_super) {
|
||||
_super.call(this);
|
||||
var obj = (_a = {},
|
||||
_a[(_super.call(this), "prop")] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
}
|
||||
return C;
|
||||
|
||||
@@ -19,7 +19,8 @@ var C = (function () {
|
||||
(function () {
|
||||
var obj = (_a = {},
|
||||
_a[_this.bar()] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
});
|
||||
return 0;
|
||||
|
||||
@@ -33,8 +33,12 @@ var C = (function (_super) {
|
||||
_super.call(this);
|
||||
(function () {
|
||||
var obj = (_a = {},
|
||||
// Ideally, we would capture this. But the reference is
|
||||
// illegal, and not capturing this is consistent with
|
||||
//treatment of other similar violations.
|
||||
_a[(_super.call(this), "prop")] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -40,7 +40,8 @@ var C = (function (_super) {
|
||||
(function () {
|
||||
var obj = (_a = {},
|
||||
_a[_super.prototype.bar.call(_this)] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
});
|
||||
return 0;
|
||||
|
||||
@@ -17,7 +17,8 @@ var C = (function () {
|
||||
C.prototype.bar = function () {
|
||||
var obj = (_a = {},
|
||||
_a[foo()] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -17,7 +17,8 @@ var C = (function () {
|
||||
C.bar = function () {
|
||||
var obj = (_a = {},
|
||||
_a[foo()] = function () { },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
return 0;
|
||||
var _a;
|
||||
};
|
||||
|
||||
@@ -6,5 +6,6 @@ var o = {
|
||||
//// [computedPropertyNames46_ES5.js]
|
||||
var o = (_a = {},
|
||||
_a["" || 0] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -16,5 +16,6 @@ var E2;
|
||||
})(E2 || (E2 = {}));
|
||||
var o = (_a = {},
|
||||
_a[E1.x || E2.x] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -25,11 +25,14 @@ var E;
|
||||
var a;
|
||||
extractIndexer((_a = {},
|
||||
_a[a] = "",
|
||||
_a)); // Should return string
|
||||
_a
|
||||
)); // Should return string
|
||||
extractIndexer((_b = {},
|
||||
_b[E.x] = "",
|
||||
_b)); // Should return string
|
||||
_b
|
||||
)); // Should return string
|
||||
extractIndexer((_c = {},
|
||||
_c["" || 0] = "",
|
||||
_c)); // Should return any (widened form of undefined)
|
||||
_c
|
||||
)); // Should return any (widened form of undefined)
|
||||
var _a, _b, _c;
|
||||
|
||||
@@ -27,24 +27,41 @@ var x = {
|
||||
|
||||
//// [computedPropertyNames49_ES5.js]
|
||||
var x = (_a = {
|
||||
p1: 10
|
||||
},
|
||||
_a.p1 = 10,
|
||||
_a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
p1: 10
|
||||
},
|
||||
Object.defineProperty(_a, 1 + 1, {
|
||||
get: function () {
|
||||
throw 10;
|
||||
}, enumerable: true, configurable: true }),
|
||||
_a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 1 + 1, {
|
||||
get: function () {
|
||||
return 10;
|
||||
}, enumerable: true, configurable: true }),
|
||||
_a[1 + 1] = Object.defineProperty({ set: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 1 + 1, {
|
||||
set: function () {
|
||||
// just throw
|
||||
throw 10;
|
||||
}, enumerable: true, configurable: true }),
|
||||
_a.foo = Object.defineProperty({ get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, "foo", {
|
||||
get: function () {
|
||||
if (1 == 1) {
|
||||
return 10;
|
||||
}
|
||||
}, enumerable: true, configurable: true }),
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
,
|
||||
_a.p2 = 20,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -32,5 +32,6 @@ var v = (_a = {},
|
||||
_a[true] = 0,
|
||||
_a["hello bye"] = 0,
|
||||
_a["hello " + a + " bye"] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -27,29 +27,37 @@ var x = {
|
||||
|
||||
//// [computedPropertyNames50_ES5.js]
|
||||
var x = (_a = {
|
||||
p1: 10,
|
||||
get foo() {
|
||||
if (1 == 1) {
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
},
|
||||
_a.p1 = 10,
|
||||
_a.foo = Object.defineProperty({ get: function () {
|
||||
p1: 10,
|
||||
get foo() {
|
||||
if (1 == 1) {
|
||||
return 10;
|
||||
}
|
||||
}, enumerable: true, configurable: true }),
|
||||
_a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
}
|
||||
},
|
||||
Object.defineProperty(_a, 1 + 1, {
|
||||
get: function () {
|
||||
throw 10;
|
||||
}, enumerable: true, configurable: true }),
|
||||
_a[1 + 1] = Object.defineProperty({ set: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 1 + 1, {
|
||||
set: function () {
|
||||
// just throw
|
||||
throw 10;
|
||||
}, enumerable: true, configurable: true }),
|
||||
_a[1 + 1] = Object.defineProperty({ get: function () {
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, 1 + 1, {
|
||||
get: function () {
|
||||
return 10;
|
||||
}, enumerable: true, configurable: true }),
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
,
|
||||
_a.p2 = 20,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -18,5 +18,6 @@ var v = (_a = {},
|
||||
_a[{}] = 0,
|
||||
_a[undefined] = undefined,
|
||||
_a[null] = null,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -16,5 +16,6 @@ var v = (_a = {},
|
||||
_a[p1] = 0,
|
||||
_a[p2] = 1,
|
||||
_a[p3] = 2,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -13,5 +13,6 @@ var E;
|
||||
})(E || (E = {}));
|
||||
var v = (_a = {},
|
||||
_a[E.member] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -15,6 +15,7 @@ function f() {
|
||||
var v = (_a = {},
|
||||
_a[t] = 0,
|
||||
_a[u] = 1,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
}
|
||||
|
||||
@@ -16,5 +16,6 @@ var v = (_a = {},
|
||||
_a[f("")] = 0,
|
||||
_a[f(0)] = 0,
|
||||
_a[f(true)] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -12,5 +12,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a[+"foo"] = "",
|
||||
_a[+"bar"] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -13,5 +13,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a["" + 0] = function (y) { return y.length; },
|
||||
_a["" + 1] = function (y) { return y.length; },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -13,5 +13,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a[+"foo"] = function (y) { return y.length; },
|
||||
_a[+"bar"] = function (y) { return y.length; },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -12,5 +12,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a[+"foo"] = function (y) { return y.length; },
|
||||
_a[+"bar"] = function (y) { return y.length; },
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -13,5 +13,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a["" + "foo"] = "",
|
||||
_a["" + "bar"] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -13,5 +13,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a[+"foo"] = "",
|
||||
_a[+"bar"] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -15,13 +15,12 @@ foo({
|
||||
|
||||
//// [computedPropertyNamesContextualType6_ES5.js]
|
||||
foo((_a = {
|
||||
p: "",
|
||||
0: function () { }
|
||||
},
|
||||
_a.p = "",
|
||||
_a[0] = function () { },
|
||||
p: "",
|
||||
0: function () { }
|
||||
},
|
||||
_a["hi" + "bye"] = true,
|
||||
_a[0 + 1] = 0,
|
||||
_a[+"hi"] = [0],
|
||||
_a));
|
||||
_a
|
||||
));
|
||||
var _a;
|
||||
|
||||
@@ -15,13 +15,12 @@ foo({
|
||||
|
||||
//// [computedPropertyNamesContextualType7_ES5.js]
|
||||
foo((_a = {
|
||||
p: "",
|
||||
0: function () { }
|
||||
},
|
||||
_a.p = "",
|
||||
_a[0] = function () { },
|
||||
p: "",
|
||||
0: function () { }
|
||||
},
|
||||
_a["hi" + "bye"] = true,
|
||||
_a[0 + 1] = 0,
|
||||
_a[+"hi"] = [0],
|
||||
_a));
|
||||
_a
|
||||
));
|
||||
var _a;
|
||||
|
||||
@@ -13,5 +13,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a["" + "foo"] = "",
|
||||
_a["" + "bar"] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -13,5 +13,6 @@ var o: I = {
|
||||
var o = (_a = {},
|
||||
_a[+"foo"] = "",
|
||||
_a[+"bar"] = 0,
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
@@ -10,9 +10,18 @@ var v = {
|
||||
var v = (_a = {},
|
||||
_a["" + ""] = 0,
|
||||
_a["" + ""] = function () { },
|
||||
_a["" + ""] = Object.defineProperty({ get: function () { return 0; }, enumerable: true, configurable: true }),
|
||||
_a["" + ""] = Object.defineProperty({ set: function (x) { }, enumerable: true, configurable: true }),
|
||||
_a);
|
||||
Object.defineProperty(_a, "" + "", {
|
||||
get: function () { return 0; },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
Object.defineProperty(_a, "" + "", {
|
||||
set: function (x) { },
|
||||
enumerable: true,
|
||||
configurable: true
|
||||
}),
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ var v = (_a = {},
|
||||
_a["hello"] = function () {
|
||||
debugger;
|
||||
},
|
||||
_a);
|
||||
_a
|
||||
);
|
||||
var _a;
|
||||
//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map
|
||||
@@ -1,2 +1,2 @@
|
||||
//// [computedPropertyNamesSourceMap2_ES5.js.map]
|
||||
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":[],"mappings":"AAAA,IAAI,CAAC,GAAG;OACH,OAAO;QACJ,QAAQ,CAAC;IACb,CAAC;OACJ,CAAA"}
|
||||
{"version":3,"file":"computedPropertyNamesSourceMap2_ES5.js","sourceRoot":"","sources":["computedPropertyNamesSourceMap2_ES5.ts"],"names":["[\"hello\"]"],"mappings":"AAAA,IAAI,CAAC,GAAG;IACJ,GAAC,OAAO,CAAC;QACLA,QAAQA,CAACA;IACbA,CAACA;;CACJ,CAAA"}
|
||||
@@ -24,45 +24,53 @@ sourceFile:computedPropertyNamesSourceMap2_ES5.ts
|
||||
4 >Emitted(1, 9) Source(1, 9) + SourceIndex(0)
|
||||
---
|
||||
>>> _a["hello"] = function () {
|
||||
1->^^^^^^^
|
||||
2 > ^^^^^^^
|
||||
3 > ^^^^->
|
||||
1->^^^^
|
||||
2 > ^^^
|
||||
3 > ^^^^^^^
|
||||
4 > ^
|
||||
5 > ^^^->
|
||||
1->{
|
||||
> [
|
||||
2 > "hello"
|
||||
1->Emitted(2, 8) Source(2, 6) + SourceIndex(0)
|
||||
2 >Emitted(2, 15) Source(2, 13) + SourceIndex(0)
|
||||
>
|
||||
2 > [
|
||||
3 > "hello"
|
||||
4 > ]
|
||||
1->Emitted(2, 5) Source(2, 5) + SourceIndex(0)
|
||||
2 >Emitted(2, 8) Source(2, 6) + SourceIndex(0)
|
||||
3 >Emitted(2, 15) Source(2, 13) + SourceIndex(0)
|
||||
4 >Emitted(2, 16) Source(2, 14) + SourceIndex(0)
|
||||
---
|
||||
>>> debugger;
|
||||
1->^^^^^^^^
|
||||
2 > ^^^^^^^^
|
||||
3 > ^
|
||||
1->]() {
|
||||
1->() {
|
||||
>
|
||||
2 > debugger
|
||||
3 > ;
|
||||
1->Emitted(3, 9) Source(3, 9) + SourceIndex(0)
|
||||
2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0)
|
||||
3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0)
|
||||
1->Emitted(3, 9) Source(3, 9) + SourceIndex(0) name (["hello"])
|
||||
2 >Emitted(3, 17) Source(3, 17) + SourceIndex(0) name (["hello"])
|
||||
3 >Emitted(3, 18) Source(3, 18) + SourceIndex(0) name (["hello"])
|
||||
---
|
||||
>>> },
|
||||
1 >^^^^
|
||||
2 > ^
|
||||
3 > ^^^^->
|
||||
3 > ^^->
|
||||
1 >
|
||||
>
|
||||
2 > }
|
||||
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0)
|
||||
2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0)
|
||||
1 >Emitted(4, 5) Source(4, 5) + SourceIndex(0) name (["hello"])
|
||||
2 >Emitted(4, 6) Source(4, 6) + SourceIndex(0) name (["hello"])
|
||||
---
|
||||
>>> _a);
|
||||
1->^^^^^^^
|
||||
2 > ^
|
||||
>>> _a
|
||||
>>>);
|
||||
1->^
|
||||
2 > ^
|
||||
3 > ^^^^^^->
|
||||
1->
|
||||
>}
|
||||
2 >
|
||||
1->Emitted(5, 8) Source(5, 2) + SourceIndex(0)
|
||||
2 >Emitted(5, 9) Source(5, 2) + SourceIndex(0)
|
||||
2 >
|
||||
1->Emitted(6, 2) Source(5, 2) + SourceIndex(0)
|
||||
2 >Emitted(6, 3) Source(5, 2) + SourceIndex(0)
|
||||
---
|
||||
>>>var _a;
|
||||
>>>//# sourceMappingURL=computedPropertyNamesSourceMap2_ES5.js.map
|
||||
@@ -7,7 +7,7 @@ declare function dec<T>(target: T): T;
|
||||
>T : T
|
||||
|
||||
@dec
|
||||
>dec : unknown
|
||||
>dec : <T>(target: T) => T
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
@@ -7,7 +7,7 @@ declare function dec<T>(target: T): T;
|
||||
>T : T
|
||||
|
||||
@dec
|
||||
>dec : unknown
|
||||
>dec : <T>(target: T) => T
|
||||
|
||||
export class C {
|
||||
>C : C
|
||||
|
||||
@@ -14,6 +14,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec get accessor() { return 1; }
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>accessor : number
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec public get accessor() { return 1; }
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>accessor : number
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec set accessor(value: number) { }
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>accessor : number
|
||||
>value : number
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec public set accessor(value: number) { }
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>accessor : number
|
||||
>value : number
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
constructor(@dec p: number) {}
|
||||
>dec : unknown
|
||||
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
|
||||
>p : number
|
||||
}
|
||||
|
||||
@@ -14,6 +14,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec method() {}
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>method : () => void
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts(5,10): error TS2331: 'this' cannot be referenced in a module body.
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod11.ts (1 errors) ====
|
||||
module M {
|
||||
class C {
|
||||
decorator(target: Object, key: string): void { }
|
||||
|
||||
@this.decorator
|
||||
~~~~
|
||||
!!! error TS2331: 'this' cannot be referenced in a module body.
|
||||
method() { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//// [decoratorOnClassMethod11.ts]
|
||||
module M {
|
||||
class C {
|
||||
decorator(target: Object, key: string): void { }
|
||||
|
||||
@this.decorator
|
||||
method() { }
|
||||
}
|
||||
}
|
||||
|
||||
//// [decoratorOnClassMethod11.js]
|
||||
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
var M;
|
||||
(function (M) {
|
||||
var C = (function () {
|
||||
function C() {
|
||||
}
|
||||
C.prototype.decorator = function (target, key) { };
|
||||
C.prototype.method = function () { };
|
||||
Object.defineProperty(C.prototype, "method",
|
||||
__decorate([
|
||||
this.decorator
|
||||
], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
return C;
|
||||
})();
|
||||
})(M || (M = {}));
|
||||
@@ -0,0 +1,15 @@
|
||||
tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts(6,10): error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class
|
||||
|
||||
|
||||
==== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod12.ts (1 errors) ====
|
||||
module M {
|
||||
class S {
|
||||
decorator(target: Object, key: string): void { }
|
||||
}
|
||||
class C extends S {
|
||||
@super.decorator
|
||||
~~~~~
|
||||
!!! error TS2338: 'super' property access is permitted only in a constructor, member function, or member accessor of a derived class
|
||||
method() { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
//// [decoratorOnClassMethod12.ts]
|
||||
module M {
|
||||
class S {
|
||||
decorator(target: Object, key: string): void { }
|
||||
}
|
||||
class C extends S {
|
||||
@super.decorator
|
||||
method() { }
|
||||
}
|
||||
}
|
||||
|
||||
//// [decoratorOnClassMethod12.js]
|
||||
var __extends = this.__extends || function (d, b) {
|
||||
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
|
||||
function __() { this.constructor = d; }
|
||||
__.prototype = b.prototype;
|
||||
d.prototype = new __();
|
||||
};
|
||||
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
var M;
|
||||
(function (M) {
|
||||
var S = (function () {
|
||||
function S() {
|
||||
}
|
||||
S.prototype.decorator = function (target, key) { };
|
||||
return S;
|
||||
})();
|
||||
var C = (function (_super) {
|
||||
__extends(C, _super);
|
||||
function C() {
|
||||
_super.apply(this, arguments);
|
||||
}
|
||||
C.prototype.method = function () { };
|
||||
Object.defineProperty(C.prototype, "method",
|
||||
__decorate([
|
||||
_super.decorator
|
||||
], C.prototype, "method", Object.getOwnPropertyDescriptor(C.prototype, "method")));
|
||||
return C;
|
||||
})(S);
|
||||
})(M || (M = {}));
|
||||
@@ -0,0 +1,29 @@
|
||||
//// [decoratorOnClassMethod13.ts]
|
||||
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
|
||||
|
||||
class C {
|
||||
@dec ["1"]() { }
|
||||
@dec ["b"]() { }
|
||||
}
|
||||
|
||||
//// [decoratorOnClassMethod13.js]
|
||||
var __decorate = this.__decorate || (typeof Reflect === "object" && Reflect.decorate) || function (decorators, target, key, desc) {
|
||||
switch (arguments.length) {
|
||||
case 2: return decorators.reduceRight(function(o, d) { return (d && d(o)) || o; }, target);
|
||||
case 3: return decorators.reduceRight(function(o, d) { return (d && d(target, key)), void 0; }, void 0);
|
||||
case 4: return decorators.reduceRight(function(o, d) { return (d && d(target, key, o)) || o; }, desc);
|
||||
}
|
||||
};
|
||||
class C {
|
||||
[_a = "1"]() { }
|
||||
[_b = "b"]() { }
|
||||
}
|
||||
Object.defineProperty(C.prototype, _a,
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, _a, Object.getOwnPropertyDescriptor(C.prototype, _a)));
|
||||
Object.defineProperty(C.prototype, _b,
|
||||
__decorate([
|
||||
dec
|
||||
], C.prototype, _b, Object.getOwnPropertyDescriptor(C.prototype, _b)));
|
||||
var _a, _b;
|
||||
@@ -0,0 +1,21 @@
|
||||
=== tests/cases/conformance/decorators/class/method/decoratorOnClassMethod13.ts ===
|
||||
declare function dec(): <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>;
|
||||
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
>target : any
|
||||
>propertyKey : string
|
||||
>descriptor : TypedPropertyDescriptor<T>
|
||||
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
>TypedPropertyDescriptor : TypedPropertyDescriptor<T>
|
||||
>T : T
|
||||
|
||||
class C {
|
||||
>C : C
|
||||
|
||||
@dec ["1"]() { }
|
||||
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
|
||||
@dec ["b"]() { }
|
||||
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
}
|
||||
@@ -14,6 +14,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec public method() {}
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
>method : () => void
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec ["method"]() {}
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec ["method"]() {}
|
||||
>dec : unknown
|
||||
>dec : () => <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
}
|
||||
|
||||
@@ -14,5 +14,5 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec public ["method"]() {}
|
||||
>dec : unknown
|
||||
>dec : <T>(target: any, propertyKey: string, descriptor: TypedPropertyDescriptor<T>) => TypedPropertyDescriptor<T>
|
||||
}
|
||||
|
||||
@@ -10,6 +10,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec method() {}
|
||||
>dec : unknown
|
||||
>dec : <T>(target: T) => T
|
||||
>method : () => void
|
||||
}
|
||||
|
||||
@@ -11,6 +11,6 @@ class C {
|
||||
|
||||
method(@dec p: number) {}
|
||||
>method : (p: number) => void
|
||||
>dec : unknown
|
||||
>dec : (target: Function, propertyKey: string | symbol, parameterIndex: number) => void
|
||||
>p : number
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec prop;
|
||||
>dec : unknown
|
||||
>dec : (target: any, propertyKey: string) => void
|
||||
>prop : any
|
||||
}
|
||||
|
||||
@@ -9,6 +9,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec prop;
|
||||
>dec : unknown
|
||||
>dec : () => <T>(target: any, propertyKey: string) => void
|
||||
>prop : any
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec public prop;
|
||||
>dec : unknown
|
||||
>dec : (target: any, propertyKey: string) => void
|
||||
>prop : any
|
||||
}
|
||||
|
||||
@@ -8,6 +8,6 @@ class C {
|
||||
>C : C
|
||||
|
||||
@dec prop;
|
||||
>dec : unknown
|
||||
>dec : (target: Function) => void
|
||||
>prop : any
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of14.ts(2,11): error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/for-ofStatements/for-of14.ts (1 errors) ====
|
||||
var v: string;
|
||||
for (v of new StringIterator) { } // Should fail because the iterator is not iterable
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2488: The right-hand side of a 'for...of' statement must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
!!! error TS2488: Type must have a '[Symbol.iterator]()' method that returns an iterator.
|
||||
|
||||
class StringIterator {
|
||||
next() {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of16.ts(2,11): error TS2489: The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.
|
||||
tests/cases/conformance/es6/for-ofStatements/for-of16.ts(2,11): error TS2489: An iterator must have a 'next()' method.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/for-ofStatements/for-of16.ts (1 errors) ====
|
||||
var v: string;
|
||||
for (v of new StringIterator) { } // Should fail
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
!!! error TS2489: The iterator returned by the right-hand side of a 'for...of' statement must have a 'next()' method.
|
||||
!!! error TS2489: An iterator must have a 'next()' method.
|
||||
|
||||
class StringIterator {
|
||||
[Symbol.iterator]() {
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
//// [for-of57.ts]
|
||||
var iter: Iterable<number>;
|
||||
for (let num of iter) { }
|
||||
|
||||
//// [for-of57.js]
|
||||
var iter;
|
||||
for (let num of iter) { }
|
||||
@@ -0,0 +1,9 @@
|
||||
=== tests/cases/conformance/es6/for-ofStatements/for-of57.ts ===
|
||||
var iter: Iterable<number>;
|
||||
>iter : Iterable<number>
|
||||
>Iterable : Iterable<T>
|
||||
|
||||
for (let num of iter) { }
|
||||
>num : number
|
||||
>iter : Iterable<number>
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
//// [iterableArrayPattern1.ts]
|
||||
var [a, b] = new SymbolIterator;
|
||||
class SymbolIterator {
|
||||
next() {
|
||||
return {
|
||||
value: Symbol(),
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//// [iterableArrayPattern1.js]
|
||||
var [a, b] = new SymbolIterator;
|
||||
class SymbolIterator {
|
||||
next() {
|
||||
return {
|
||||
value: Symbol(),
|
||||
done: false
|
||||
};
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern1.ts ===
|
||||
var [a, b] = new SymbolIterator;
|
||||
>a : symbol
|
||||
>b : symbol
|
||||
>new SymbolIterator : SymbolIterator
|
||||
>SymbolIterator : typeof SymbolIterator
|
||||
|
||||
class SymbolIterator {
|
||||
>SymbolIterator : SymbolIterator
|
||||
|
||||
next() {
|
||||
>next : () => { value: symbol; done: boolean; }
|
||||
|
||||
return {
|
||||
>{ value: Symbol(), done: false } : { value: symbol; done: boolean; }
|
||||
|
||||
value: Symbol(),
|
||||
>value : symbol
|
||||
>Symbol() : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
|
||||
done: false
|
||||
>done : boolean
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
return this;
|
||||
>this : SymbolIterator
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts(2,5): error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'.
|
||||
Property '0' is missing in type 'FooIterator'.
|
||||
|
||||
|
||||
==== tests/cases/conformance/es6/destructuring/iterableArrayPattern10.ts (1 errors) ====
|
||||
function fun([a, b]) { }
|
||||
fun(new FooIterator);
|
||||
~~~~~~~~~~~~~~~
|
||||
!!! error TS2345: Argument of type 'FooIterator' is not assignable to parameter of type '[any, any]'.
|
||||
!!! error TS2345: Property '0' is missing in type 'FooIterator'.
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//// [iterableArrayPattern10.ts]
|
||||
function fun([a, b]) { }
|
||||
fun(new FooIterator);
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//// [iterableArrayPattern10.js]
|
||||
function fun([a, b]) { }
|
||||
fun(new FooIterator);
|
||||
class Bar {
|
||||
}
|
||||
class Foo extends Bar {
|
||||
}
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//// [iterableArrayPattern11.ts]
|
||||
function fun([a, b] = new FooIterator) { }
|
||||
fun(new FooIterator);
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//// [iterableArrayPattern11.js]
|
||||
function fun([a, b] = new FooIterator) { }
|
||||
fun(new FooIterator);
|
||||
class Bar {
|
||||
}
|
||||
class Foo extends Bar {
|
||||
}
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern11.ts ===
|
||||
function fun([a, b] = new FooIterator) { }
|
||||
>fun : ([a, b]?: FooIterator) => void
|
||||
>a : Foo
|
||||
>b : Foo
|
||||
>new FooIterator : FooIterator
|
||||
>FooIterator : typeof FooIterator
|
||||
|
||||
fun(new FooIterator);
|
||||
>fun(new FooIterator) : void
|
||||
>fun : ([a, b]?: FooIterator) => void
|
||||
>new FooIterator : FooIterator
|
||||
>FooIterator : typeof FooIterator
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Bar
|
||||
>x : any
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Foo
|
||||
>Bar : Bar
|
||||
>y : any
|
||||
|
||||
class FooIterator {
|
||||
>FooIterator : FooIterator
|
||||
|
||||
next() {
|
||||
>next : () => { value: Foo; done: boolean; }
|
||||
|
||||
return {
|
||||
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
|
||||
|
||||
value: new Foo,
|
||||
>value : Foo
|
||||
>new Foo : Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
done: false
|
||||
>done : boolean
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
return this;
|
||||
>this : FooIterator
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//// [iterableArrayPattern12.ts]
|
||||
function fun([a, ...b] = new FooIterator) { }
|
||||
fun(new FooIterator);
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//// [iterableArrayPattern12.js]
|
||||
function fun([a, ...b] = new FooIterator) { }
|
||||
fun(new FooIterator);
|
||||
class Bar {
|
||||
}
|
||||
class Foo extends Bar {
|
||||
}
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
=== tests/cases/conformance/es6/destructuring/iterableArrayPattern12.ts ===
|
||||
function fun([a, ...b] = new FooIterator) { }
|
||||
>fun : ([a, ...b]?: FooIterator) => void
|
||||
>a : Foo
|
||||
>b : Foo[]
|
||||
>new FooIterator : FooIterator
|
||||
>FooIterator : typeof FooIterator
|
||||
|
||||
fun(new FooIterator);
|
||||
>fun(new FooIterator) : void
|
||||
>fun : ([a, ...b]?: FooIterator) => void
|
||||
>new FooIterator : FooIterator
|
||||
>FooIterator : typeof FooIterator
|
||||
|
||||
class Bar { x }
|
||||
>Bar : Bar
|
||||
>x : any
|
||||
|
||||
class Foo extends Bar { y }
|
||||
>Foo : Foo
|
||||
>Bar : Bar
|
||||
>y : any
|
||||
|
||||
class FooIterator {
|
||||
>FooIterator : FooIterator
|
||||
|
||||
next() {
|
||||
>next : () => { value: Foo; done: boolean; }
|
||||
|
||||
return {
|
||||
>{ value: new Foo, done: false } : { value: Foo; done: boolean; }
|
||||
|
||||
value: new Foo,
|
||||
>value : Foo
|
||||
>new Foo : Foo
|
||||
>Foo : typeof Foo
|
||||
|
||||
done: false
|
||||
>done : boolean
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
>Symbol.iterator : symbol
|
||||
>Symbol : SymbolConstructor
|
||||
>iterator : symbol
|
||||
|
||||
return this;
|
||||
>this : FooIterator
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
//// [iterableArrayPattern13.ts]
|
||||
function fun([a, ...b]) { }
|
||||
fun(new FooIterator);
|
||||
class Bar { x }
|
||||
class Foo extends Bar { y }
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
//// [iterableArrayPattern13.js]
|
||||
function fun([a, ...b]) { }
|
||||
fun(new FooIterator);
|
||||
class Bar {
|
||||
}
|
||||
class Foo extends Bar {
|
||||
}
|
||||
class FooIterator {
|
||||
next() {
|
||||
return {
|
||||
value: new Foo,
|
||||
done: false
|
||||
};
|
||||
}
|
||||
[Symbol.iterator]() {
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user